How Java wrapper names are aliased

The EGL generator applies the following rules to alias Java™ wrapper names:

  1. If the EGL name is all uppercase, convert it to lowercase.
  2. If the name is a class name or a method name, make the first character uppercase. (For example, the getter method for x is getX() not getx().)
  3. Delete every underscore (_) and hyphen (-). (Hyphens are valid in EGL names if you use VisualAge® Generator compatibility mode.) If a letter follows the underscore or hyphen, change that character to uppercase.
  4. If the name is a qualified name that uses a period (.) as a separator, replace every period with an underscore, and add an underscore at the beginning of the name.
  5. If the name contains a dollar sign ($), replace the dollar sign with two underscores and add an underscore at the beginning of the name.
  6. If a name is a Java keyword, add an underscore at the beginning of the name.
  7. If the name is * (an asterisk, which represents a filler field), rename the first asterisk Filler1, the second asterisk Filler2, and so forth.

In addition, special rules apply to Java wrapper class names for program wrappers, record wrappers, and substructured array fields. The remaining sections discuss these rules and give an example. In general, if naming conflicts exist between fields within a generated wrapper class, the qualified name is used to determine the class and variable names. If the conflict is still not resolved, an exception is thrown at generation time.

Program wrapper class

Record parameter wrappers are named by using the above rules applied to the type definition name. If the record wrapper class name conflicts with the program class name or the program wrapper class name, Record is added at the end of the record wrapper class name.

The rules for variable names are as follows:
  1. The record parameter variable is named using above rules applied to the parameter name. Therefore, the get() and set() methods contain these names rather than the class name.
  2. The get and set methods are named get or set followed by the parameter name with the above rules applied.

Record wrapper class

The rules for substructured array fields class names are as follows:
  1. The substructured array field becomes an inner class of the record wrapper class, and the class name is derived by applying the above rules to the field name. If this class name conflicts with the containing record class name, Structure is appended to the field class name.
  2. If any field class names conflict with each other, the qualified field names are used.
The rules for get and set method names are as follows:
  1. The methods are named get or set followed by the field name with the above rules applied.
  2. If any field names conflict with each other, the qualified field names are used.

Substructured array field class

The rules for substructured array field class names are as follows:
  1. The substructured array field becomes an inner class of the wrapper class generated for the containing substructured array field , and the class name is derived by applying the above rules to the field name.
  2. If this class name conflicts with the containing substructured array field class name, Structure is appended to the field class name.
The rules for get and set method names are as follows:
  1. The methods are named get or set followed by the field name with the above rules applied.
  2. If any field names conflict with each other, the qualified field names are used.

Example

The following sample program and generated output show what should be expected during wrapper generation:

Sample program

Program WrapperAlias(param1 RecordA)
  
end

Record RecordA type basicRecord
	10 fieldA CHAR(10)[1];
	10 field_b CHAR(10)[1];
	10 field$C CHAR(10)[1];
	10 static CHAR(10)[1];
	10 fieldC CHAR(20)[1];
		15 field CHAR(10)[1];
		15 fieldD CHAR(10)[1];
	10 arrayField CHAR(20)[5];
		15 innerField1 CHAR(10)[1];
		15 innerField2 CHAR(10)[1];
end

Generated output

Names of generated output
Output Name
Program wrapper class WrapperaliasWrapper, containing a field param1, which is an instance of the record wrapper class RecordA
Parameter wrapper classes RecordA, accessible through the following methods:
  • getFieldA (from fieldA)
  • getFieldB (from the first field-b)
  • get_Field__C (from field$C)
  • get_Static (from static)
  • get_FieldC_itemB (from fieldB in fieldC)
  • getFieldD (from fieldD)
  • getArrayField (from arrayField)
ArrayField is an inner class of RecordA that contains fields that can be accessed through getInnerField1 and getInnerField2.

Feedback