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

5.6.2 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.

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"0000" 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 N(50). 
01  aString       OBJECT REFERENCE J-String.
 ...
PROCEDURE DIVISION.
 ...
 MOVE NC"Two-byte-code" TO initialValue.
 INVOKE J-String "NEW-STRING-N" USING initialValue RETURNING aString.  [1]
 ...
 MOVE NC"Two-byte-code" & X"0000" TO initialValue.
 INVOKE J-String "NEW-STRING-N" 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.