Parameter and return value, Supplement, New-string-n method (factory method) – FUJITSU J Adapter Class Generator User Manual

Page 62: Explanation, Syntax

Advertising
background image

62 Chapter 5. Adapter Class Reference

Parameter and return value
• class-name

Specifies the internal class name of the java-lang-String class declared in the

REPOSITORY paragraph.

• initialValue (attribute: PIC X ANY LENGTH)

Specifies an alphanumeric data item as the initial value of the String object.

• createdObject (attribute: OBJECT REFERENCE SELF)

Returns the generated object.

Supplement
When a data name is specified for initialValue, a String object as long as data item

length is generated. However, inserting X”00” in the statement can generate a

String object shorter than data item length.

...
REPOSITORY.
CLASS J-String AS "java-lang-String"
...
WORKING-STORAGE SECTION.
01 initialValue PIC X(50).
01 aString OBJECT REFERENCE J-String.
...
PROCEDURE DIVISION.
...
MOVE "ABC" TO initialValue.
INVOKE J-String "NEW-STRING-X" USING initialValue RETURNING aString.
[1]
...
MOVE "ABC" & X"00" TO initialValue.
INVOKE J-String "NEW-STRING-X" USING initialValue RETURNING aString.
[2]

1. A String object consisting of 50 characters with the last 47-character area

padded with blanks is generated.

2. A String object consisting of three characters is generated.

NEW-STRING-N method (factory method)

Explanation
This method generates a String object having the character string specified for the

national data item as an initial value.
Syntax
INVOKE

class-name

"NEW-STRING-N" USING

initialValue

RETURNING

createdObject

Parameter and return value
• class-name

Specifies the internal class name of the java-lang-String class declared in the

REPOSITORY paragraph.

• initialValue (attribute: PIC N ANY LENGTH)

Specifies a national data item as the initial value of the String object.

Advertising