Explanation
An adapter class corresponding to the array is generated when:
An array is used as a parameter of a public constructor.
The type of a public field (static or non-static) is an array.
An array is used as a parameter or return value of a public method (static or non-static).
Arrays whose attributes shown below match are associated with the same adapter class:
Array element type
Number of dimensions
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
Internal class names 1 and 2 are internally used by the J adapter class generator and are not viewed from the class user.
The external class name is used to identify the class. The class user can identify the class with the external class name.
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.
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. |
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.
One-dimensional array having a JA-2-int class object as an element
One-dimensional array having a JA-1-int class object as an element
One-dimensional array having int as an element
Note
No array exceeding 9 dimensions can be handled.