Defining typed data elements

To declare typed data elements at configuration or installation time, modify the XML files using the CHA Editor or any ASCII editor. These typed data elements can be dynamically updated at runtime. Define typed data elements in the data definition file. The types definition file should only be used as a repository of generic types. The typed data elements defined in the data file can reference these generic types and override some of type generic properties depending on what the data element requires.

The following are example definitions of data elements as they might appear in a typed data definition file:

Example 1: Instantiate a typed data field of type money.

Typed data definition
<type id="Money" implClass="com.ibm.btt.base.DataField">
  <Descriptor id="typeDefault"
implClass="com.ibm.btt.base.types.ext.FloatDescriptor">
    <Converter convTypes="default" 
        implClass="com.ibm.btt.base.types.ext.FloatConverter"/>
    <Validator
implClass="com.ibm.btt.base.types.ext.FloatValidator" 
        lowerLimit="0"/>
  </Descriptor >
</kColl> 
Code
DataField elem1 = (DataField)
DSEType.readObject("Money");
elem1.setValue(new Float("200")); 

Example 2: Instantiate a typed keyed collection of type account and set its balance to 200.

Typed data definition
<type id="AccountNumber"
implClass="com.ibm.btt.base.DataField">
  <Descriptor id="typeDefault" 
     
implClass="com.ibm.btt.base.types.ext.StringPropertyDescriptor">
    <Converter convTypes="default,xml" 
        implClass="com.ibm.btt.base.types.ext.StringConverter"/>
    <Validator
implClass="com.ibm.btt.base.types.ext.IntegerStringValidator"
        minLength="8" maxLength="8"/> 
  </Descriptor>
</type>
<type id="Account"
implClass="com.ibm.btt.base.KeyedCollection">
  <KCollDescriptor id="typeDefault" refType="Account"/>
  <StringDescriptor id="accountNumber" refType="AccountNumber"
initialValue="12345678" 
      isMandatory="true"/> 
  <FloatDescriptor id="accountBalance" refType="Money"
initialValue="50" 
      upperLimit="100000"/>
</type> 
Code
KeyedCollection kColl = (KeyedCollection)
DSEType.readObject("Account");
kColl.setValueAt("accountBalance", new Float("200"));
Note: To ensure optimum performance in the type instantiation process, all default descriptors for types should include the implClass attribute in their definition. The rest of descriptors should also have the implClass attribute defined although the system can get the implementation class from the default descriptor of the type identified by the refType attribute.

Example 3: Instantiate the myBalance typed data field defined in the data definition file and set its balance to 200.

Definition in the toolkit types definition file:
<type id="Money" implClass="com.ibm.btt.base.DataField">
  <Descriptor id="typeDefault"
implClass="com.ibm.btt.base.types.ext.FloatDescriptor">
    <Converter convTypes="default"
implClass=com.ibm.btt.base.types.ext.FloatConverter/>
    <Validator
implClass="com.ibm.btt.base.types.ext.FloatValidator"
lowerLimit="0"/>
  </Descriptor >
</kColl> 
Definition in the toolkit data definition file:
<data id="myBalance" refType="Money" value="1000"/>
Code
DataField elem1 = (DataField)DataElement.readObject("myBalance");
elem1.setValue(new Float("200"));