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

5.5.6 Instance variable

Explanation

A public instance variable (non-static field) is mapped to a COBOL property method (object).

Expansion format

METHOD-ID. GET PROPERTY property-name.
    ...
LINKAGE SECTION.
01 property-value data-description-entry.
PROCEDURE DIVISION RETURNING property-value.
    ...
END METHOD property-name.
METHOD-ID. SET PROPERTY property-name.
    ...
LINKAGE SECTION.
01 property-value data-description-entry
PROCEDURE DIVISION USING property-value.
    ...
END METHOD property-name.

Generation rules

  1. The property name is used to identify the property. The class user can identify the property with the property name.

  2. A property name is generated according to the following rules:

    JF-JavaFieldName[-nn]
    • "JF-" is followed by a Java field name in uppercase.

    • If a same property name has already been assigned, the second and subsequent property names are each suffixed with a hyphen "-" followed by a two-digit number (01 to 99) to prevent name duplication. (see "5.8 Numbering Names".)

    • A name exceeding 30 characters is truncated after the 30th character.

  3. When FINAL is specified, no property method with the SET specification is generated.

  4. The property value is a parameter used to transfer a property value. The data description entry expands the COBOL description entry corresponding to the Java field attribute. See "5.5.1 Data types" for the correspondence of data types.

Generation rules

The property method corresponding to the instance variable nval of the java.io.StreamTokenizer class is generated as shown below:

METHOD-ID. GET PROPERTY JF-NVAL.                      [1]
    ...
LINKAGE SECTION.
01  GET-VALUE  COMP-2.                                [2]
PROCEDURE DIVISION RETURNING GET-VALUE.
    ...
END METHOD JF-NVAL.
METHOD-ID. SET PROPERTY JF-NVAL.                      [3]
    ...
LINKAGE SECTION.
01  SET-VALUE  COMP-2. 
PROCEDURE DIVISION USING SET-VALUE.
    ...
END METHOD JF-NVAL.
  1. The property name is generated by adding "NVAL", which is the uppercase of the Java field name, to "JF-".

  2. "nval" is mapped to COMP-2 because its attribute is double.

  3. Since FINAL is not specified, a property method with the SET specification is also generated.

Supplement

When a property name is generated from a field name, a number is assigned to secure the uniqueness of the name. The class browser can be used to check the correspondence between fields and properties.