How Java™ wrapper names are aliased
The EGL generator applies the following rules to alias Java™ wrapper names:
- If the EGL name is all uppercase, convert it to lowercase.
- 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().)
- 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.
- 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.
- If the name contains a dollar sign ($), replace the dollar sign with two underscores and add an underscore at the beginning of the name.
- If a name is a Java™ keyword, add an underscore at the beginning of the name.
- 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 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.
- The get and set methods are named get or set followed by the parameter name with the above rules applied.
Record wrapper class
- 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.
- If any field class names conflict with each other, the qualified field names are used.
- The methods are named get or set followed by the field name with the above rules applied.
- If any field names conflict with each other, the qualified field names are used.
Substructured array field class
- 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.
- If this class name conflicts with the containing substructured array field class name, Structure is appended to the field class name.
- The methods are named get or set followed by the field name with the above rules applied.
- 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
| 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:
|