Top
NetCOBOL V11.0 J Adapter Class GeneratorUser's Guide
FUJITSU Software

5.6.1 NEW-STRING-X method (factory method)

Explanation

This method generates a String object having the character string specified for the alphanumeric data item as an initial value.

Syntax

INVOKE class-name "NEW-STRING-X" 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 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.