To define a new data element with the behavior required for the HostField data element, create a new class called HostField that extends DataField (see Extending data elements). This class adds an attribute that represents the backend system field identifier, as follows:
class HostField extends DataField { String hostIdentifier; }
Add the corresponding setter and getter methods, setHostIdentifier() and getHostIdentifier().
To enable initialization of the object from its definition in the entity definition file, override the initializeFrom method to parse the new hostId tag. The new method is implemented as follows:
public Object initializeFrom(Tag aTag) throws java.io.IOException { super.initializeFrom(aTag); for (int i=0;i<aTag.getAttrList().size();i++) { TagAttribute attribute = (TagAttribute) Tag.getAttrList().elementAt(i); if (attribute.getName().equals("hostId")) setHostIdentifier((String) (attribute.getValue())); } return this; }
The new formatters, HostDecorator and HostStringFormat, are also coded to extend the toolkit. Browse the com.ibm.dse.samples.appl package to see the classes HostStringFormat and HostDecorator class implementations.