Fujitsu J Adapter Class Generator Portable Generator User Manual


 
26 Chapter 3. Developing Programs
An example of assigning an object, which has been referenced with Object class
data, into Data class data is shown below:
...
REPOSITORY.
CLASS J-Object AS "java-lang-Object"
CLASS J-Date AS "java-util-Date"
...
WORKING-STORAGE SECTION
01 anDate OBJECT REFERENCE J-Date.
01 anObject OBJECT REFERENCE J-Object.
...
PROCEDURE DIVISION.
...
INVOKE J-Date "J-NARROW" USING CONTENT anObject RETURNING anDate.
...
Mapping java.lang.String into PIC X
The java.lang.String is mapped into the java-lang-String class in the generation of
the normal adapter class. In this case, creation of the user's application becomes
somewhat complicated because conversion between the String object and the
COBOL data items must be performed using the java-lang-String class method (such
as NEW-STRING-X, GET-STRING-X).
When the adapter class is generated by specifying the -s option or by specifying the
"Option String" parameter, the following items can be handled as alphanumeric items
in the user's applications, since the java.lang.String type is mapped into PIC X ANY
LENGTH:
Return values of the java.lang.String type in the method
Argument of the java.lang.String type in the constructor and method
Fields (class variables and instance variables) of the java.lang.String type
Example: When the -s option and "Option String" parameter are not specified, the
conversion between the String object and the COBOL data items must be performed
in the user's application using the java-lang-String class method (such as NEW-
STRING-X and GET-STRING-X).
REPOSITORY.
CLASS J-Date AS "java-util-Date"
CLASS J-String AS "java-lang-String"
CLASS J-DateFormat AS "java-text-DateFormat"
WORKING-STORAGE SECTION
01 aDateFormat OBJECT REFERENCE J-DateFormat.
01 aDate OBJECT REFERENCE J-Date.
01 dateString OBJECT REFERENCE J-String.
01 dateValue PIC X(30).
PROCEDURE DIVISION.
MOVE "2000/01/01" & X"00" TO dateValue.
INVOKE J-String "NEW-STRING-X" USING dateValue RETURNING dateString.
INVOKE aDateFormat "parse" USING dateString RETURNING aDate.
INVOKE aDate "toString" RETURNING dateString.
INVOKE dateString "GET-STRING-X" RETURNING dateValue.