|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectcom.microfocus.cobol.lang.Pointer
Pointer class is a helper class for passing String/StringBuffer to COBOL in a type-safe manor
Copyright: Copyright (c) 2002-2003
| Constructor Summary | |
Pointer(byte[] bytes)
Construct a Pointer to a bytes[] array. CAUTION You must ensure the length of the byte[] is the same as the picture clause defined in the COBOL program. |
|
Pointer(String initString)
Constructor a Pointer to a string for passing to a COBOL program CAUTION You must ensure the size of Java string is the same as the size defined in the COBOL programs picture clause. |
|
Pointer(StringBuffer initString)
Construct a Pointer to a StringBuffer for passing to a COBOL program CAUTION You must ensure the capacity of StringBuffer is large enough to be passed into the COBOL program. |
|
Pointer(StringBuffer initString,
String encoding)
Construct a Pointer to a StringBuffer given a specific encoding. |
|
Pointer(String initString,
int capacity)
Construct a Pointer to a string with a set capacity for passing to a COBOL program. |
|
Pointer(String initString,
int capacity,
String encoding)
Construct a Pointer to a string with a set capacity for passing to a COBOL program. |
|
Pointer(String initString,
int capacity,
String encoding,
String filler)
Construct a Pointer to a string with a set capacity for passing to a COBOL program. |
|
Pointer(String initString,
String encoding)
Construct a fixed length string with a specific encoding. CAUTION You must ensure the size of Java string is the same as the size defined in the COBOL programs picture clause. |
|
| Method Summary | |
Object |
clone()
clone method |
byte[] |
getBytes()
Internal class method that returns a byte[] that represents its COBOL value for use in cobcall(). |
String |
getEncoding()
get the encoding (or default if not set) |
void |
setEncoding(String encoding)
set the encoding for Pointer See sun's site for supported encodings |
void |
synchronizeData()
Internal class method that is called when the COBOL byte[] (from getBytes()) is changed by the COBOL program. |
String |
toString()
Returns a String representation of the Pointer in the specified encoding |
| Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public Pointer(byte[] bytes)
For example to pass a byte[20] to a COBOL program that expects the value
in pic x(20)
The Java would be:
public static void main(String[] args) throws Exception
{
StringBuffer myString = new StringBuffer();
myString.append("Hello from Java 1234"); // filled to size 20
byte ourBytes[] = myString.toString().getBytes(); // get byte[]
Object parms[] = { new Pointer(ourBytes) }; // setup parameters
Runtime.cobcall("showbytes",parms); // call our program
System.out.println(new String(ourBytes));
}
and the COBOL would be:
working-storage section.
linkage section.
01 lnk-string pic x(20).
procedure division using lnk-string.
display "lnk-string = " lnk-string.
move "Hello from COBOL" to lnk-string.
exit program returning 0.
bytes - a byte[]RuntimeSystem.cobcall(java.lang.Object, java.lang.String, java.lang.Object[], int[], boolean),
RuntimeSystem.ccall(java.lang.Object, java.lang.String, java.lang.Object[], int[])public Pointer(StringBuffer initString)
For example to pass a StringBuffer with at least a capacity of 20
to a COBOL program that expects the value in pic x(20)
public static void main(String[] args) throws Exception
{
StringBuffer myString = new StringBuffer();
myString.ensureCapacity(20); // size of at least 20
myString.append("Hello from Java");
Object parms[] = { new Pointer(myString) }; // setup parameters
Runtime.cobcall("showbytes",parms); // call our program
System.out.println(new String(myString));
}
and the COBOL would be:
working-storage section.
linkage section.
01 lnk-string pic x(20).
procedure division using lnk-string.
display "lnk-string = " lnk-string.
move "Hello from COBOL" to lnk-string.
exit program returning 0.
initString - a stringbuffer with a capacity specified via ensureCapacity()RuntimeSystem.cobcall(java.lang.Object, java.lang.String, java.lang.Object[], int[], boolean),
RuntimeSystem.ccall(java.lang.Object, java.lang.String, java.lang.Object[], int[])
public Pointer(StringBuffer initString,
String encoding)
throws UnsupportedEncodingException
initString - encoding -
UnsupportedEncodingExceptionPointer(StringBuffer)public Pointer(String initString)
initString - Pointer(String,int),
RuntimeSystem.cobcall(java.lang.Object, java.lang.String, java.lang.Object[], int[], boolean),
RuntimeSystem.ccall(java.lang.Object, java.lang.String, java.lang.Object[], int[])
public Pointer(String initString,
String encoding)
throws UnsupportedEncodingException
initString - encoding -
UnsupportedEncodingException
public Pointer(String initString,
int capacity)
initString - capacity - RuntimeSystem.cobcall(java.lang.Object, java.lang.String, java.lang.Object[], int[], boolean),
RuntimeSystem.ccall(java.lang.Object, java.lang.String, java.lang.Object[], int[])
public Pointer(String initString,
int capacity,
String encoding)
throws UnsupportedEncodingException
initString - capacity - encoding -
UnsupportedEncodingExceptionRuntimeSystem.cobcall(java.lang.Object, java.lang.String, java.lang.Object[], int[], boolean),
RuntimeSystem.ccall(java.lang.Object, java.lang.String, java.lang.Object[], int[])
public Pointer(String initString,
int capacity,
String encoding,
String filler)
throws UnsupportedEncodingException
initString - capacity - encoding - filler -
UnsupportedEncodingExceptionRuntimeSystem.cobcall(java.lang.Object, java.lang.String, java.lang.Object[], int[], boolean),
RuntimeSystem.ccall(java.lang.Object, java.lang.String, java.lang.Object[], int[])| Method Detail |
public void synchronizeData()
synchronizeData in interface DataTypeDataType,
getBytes()public byte[] getBytes()
getBytes in interface DataTypeDataTypepublic String toString()
public Object clone()
throws CloneNotSupportedException
CloneNotSupportedExceptionpublic String getEncoding()
public void setEncoding(String encoding)
throws UnsupportedEncodingException
encoding -
UnsupportedEncodingException
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
Copyright © 2000 Micro Focus International Limited. All rights reserved.
This document and the proprietary marks and names used herein are protected by international law.