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

5.7.1 Array class

Explanation

An adapter class corresponding to the array is generated when:

Arrays whose attributes shown below match are associated with the same adapter class:

Expansion format

CLASS-ID. internal-class-1 AS "external-class-name" INHERITS internal-class-name-2.
    ...
FACTORY.
    ...
  <<NEW-ARRAY method>>
END FACTORY.
OBJECT.
    ...
  <<GET-ARRAY-LENGTH method>>
  <<GET-ARRAY-ELEMENT method>>
  <<SET-ARRAY-ELEMENT method>>
END OBJECT.
END CLASS internal-class-name-1.

Generation rules

  1. Internal class names 1 and 2 are internally used by the J adapter class generator and are not viewed from the class user.

  2. The external class name is used to identify the class. The class user can identify the class with the external class name.

  3. An external class name is generated according to the following rules:

    JA-NumberOfDimensions-ElementTypeName
    • "JA-" is followed by the number of dimensions (1 to 9) and element type name with a hyphen "-" inserted in between them.

    • An element type name is generated depending on the type in the following format:

      • Object: External class name of the adapter class corresponding to the Java class (see "5.5.2 Class and interface".)

      • Basic type: Java keyword representing a type (boolean, byte, char, short, int, long, float, or double)

    • An external class name exceeding 160 characters is truncated after the 160th character.

  4. The following methods are generated in the factory or method definition:

    Method name

    Type

    Function

    NEW-ARRAY

    Factory

    Generates an array object.

    GET-ARRAY-LENGTH

    Object

    Obtains the number of elements of an array.

    GET-ARRAY-ELEMENT

    Object

    Fetches a value from an array element.

    SET-ARRAY-ELEMENT

    Object

    Sets a value in an array element.

  5. An n-dimensional array is handled as a one-dimensional array having an n-1-dimensional array as an element. Therefore, for n-dimensional array, n adapter classes (JA-n-XYZ, JA-(n-1)-XYZ, ..., JA-1-XYZ) are generated. JA-n-XYZ is a one-dimensional array having JA-(n-1)-XYZ as an element.

Generation example

The adapter class for java.lang.String[] is generated as shown below:

CLASS-ID. JA-1-STRING AS "JA-1-java-lang-String" INHERITS J-OBJECT. 
    ...
END CLASS JA-1-STRING.

Adapter classes of int [] [] [] are generated as shown below:

CLASS-ID. JA-3-INT AS "JA-3-int" INHERITS J-OBJECT.             [1]
    ...
END CLASS JA-3-INT.
CLASS-ID. JA-2-INT AS "JA-2-int" INHERITS J-OBJECT.             [2]
    ...
END CLASS JA-2-INT.
CLASS-ID. JA-1-INT AS "JA-1-int" INHERITS J-OBJECT.             [3]
    ...
END CLASS JA-1-INT.
  1. One-dimensional array having a JA-2-int class object as an element

  2. One-dimensional array having a JA-1-int class object as an element

  3. One-dimensional array having int as an element

Note

No array exceeding 9 dimensions can be handled.