EGL Reference Guide for iSeries

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 a low line, and add a low line at the beginning of the name.
  5. If the name contains a dollar sign ($), replace the dollar sign with two low lines and add a low line at the beginning of the name.
  6. If a name is a Java keyword, add a low line at the beginning of the name.
  7. If the name is * (an asterisk, which represents a filler item), 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 items. 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 items class names are as follows:

  1. The substructured array item becomes an inner class of the record wrapper class, and the class name is derived by applying the above rules to the item name. If this class name conflicts with the containing record class name, Structure is appended to the item class name.
  2. If any item class names conflict with each other, the qualified item 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 item name with the above rules applied.
  2. If any item names conflict with each other, the qualified item names are used.

Substructured array items class

The rules for substructured array items class names are as follows:

  1. The substructured array item becomes an inner class of the wrapper class generated for the containing substructured array item , and the class name is derived by applying the above rules to the item name.
  2. If this class name conflicts with the containing substructured array item class name, Structure is appended to the item class name.

The rules for get and set method names are as follows:

  1. The methods are named get or set followed by the item name with the above rules applied.
  2. If any item names conflict with each other, the qualified item 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 itemA CHAR(10)[1];
	10 item_b CHAR(10)[1];
	10 item$C CHAR(10)[1];
	10 static CHAR(10)[1];
	10 itemC CHAR(20)[1];
		15 item CHAR(10)[1];
		15 itemD CHAR(10)[1];
	10 arrayItem CHAR(20)[5];
		15 innerItem1 CHAR(10)[1];
		15 innerItem2 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:
  • getItemA (from itemA)
  • getItemB (from the first item-b)
  • get_Item__C (from item$C)
  • get_Static (from static)
  • get_ItemC_itemB (from itemB in itemC)
  • getItemD (from itemD)
  • getArrayItem (from arrayItem)
ArrayItem is an inner class of RecordA that contains fields that can be accessed through getInnerItem1 and getInnerItem2.


Related concepts
Compatibility with VisualAge Generator
Java wrapper
Name aliasing


Related tasks
Generating Java wrappers


Related reference
How names are aliased
Java wrapper classes
Naming conventions
Output of Java wrapper generation


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]