Runtime tools : Core components : Typed data : Reference : Typed data definition examples in the type definition file
  
Typed data definition examples in the type definition file
The following typed data definition example defines a typed DataField named Date. The default descriptor for the Date data definition defines a converter that handles XML and default conversions. The converter takes a mask parameter. The DateConverter uses this mask as a pattern to perform the conversions. The definition also associates a validator that only allows dates in the year 2000.
<type id="Date" implClass="com.ibm.btt.base.DataField">
<Descriptor id="typeDefault" refType="Date"

implClass="com.ibm.btt.base.types.ext.DatePropertyDescriptor">
<Converter convTypes="default,xml"
implClass="com...ext.DateConverter"
mask="dd.MM.yyyy"/>
<Validator
implClass="com.ibm.btt.base.types.ext.DateValidator"
mask="dd.MM.yyyy"
lowerLimit="01.01.2000" upperLimit="31.12.2000"/>
</Descriptor>
</type>
The following typed data definition example defines a typed DataField named Money. The default descriptor for the Money typed data definition defines two converters: one for default conversion type and another for the host conversion type. Although the implementation class for both converters is the same, the definition cannot use a comma separated list of conversion types because they require different parameters. The definition is also a validator that takes no parameters.
<type id="Money" implClass="com.ibm.btt.base.DataField">
<Descriptor id="typeDefault"

implClass="com.ibm.btt.base.types.ext.FloatPropertyDescriptor">
<Converter convTypes="default"
implClass="com.ibm.btt.base.types.ext.FloatConverter"
size="4"/>
<Converter convTypes="host"
implClass="com.ibm.btt.base.types.ext.FloatConverter"
binaryConversion="true" size="4"/>
<Validator
implClass="com.ibm.btt.base.types.ext.FloatValidator"
lowerLimit="0"/>
</Descriptor>
</type>
The following typed data definition example defines a typed DataField named AccountNumber. The default descriptor for the AccountNumber typed data definition also defines a converter that handles XML and default conversions. In this case, the converter takes no parameters. It has also one validator with the parameters minLength and maxLength set to 8. This validator checks that the data element of this type has as value a numeric String of exactly eight digits.
<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>
The following typed data definition example defines a typed KeyedCollection named FundsTransferData. The FundsTransferData data definition has a default descriptor with the implClass attribute set to KCollDescriptor. This descriptor defines an instance of the KCollValidator as a validator that validates each of the elements contained in the KeyedCollection. The FundsTransferData data definition specifies four descriptors that define its structure: two of AccountNumber type called accountTo and accountFrom, one of Money type called amount, and one of Date type called transactionDate. The third descriptor overrides the default behavior for Money in general by specifying an upperLimit to be used by the validator. In the case of this definition, the maximum fund transfer amount is 1000.
<type id="FundsTransfer"
implClass="com.ibm.btt.base.KeyedCollection" >
<Descriptor id="typeDefault" refType="FundsTransfer"

implClass="com.ibm.btt.base.types.ext.KCollPropertyDescriptor">
<Validator
implClass="com.ibm.btt.base.types.KCollValidator"/>
</Descriptor>
<Descriptor id="accountFrom" refType=" AccountNumber "
initialValue="2345"
isMandatory="true"/>
<Descriptor id="accountTo" refType="AccountNumber "
initialValue="678589"
isMandatory="true"/>
<Descriptor id="amount" refType="Money" initialValue="100"
isMandatory="true"
upperLimit="1000"/>
<Descriptor id="transactionDate" refType="Date"
mask="dd.MM.yy"/>
</type>
Note The KCollValidator can only validate each of the elements contained in the keyed collection separately, and does not perform any cross-validation. If you require this cross-validation (for example, to check that the accountFrom value is different from the accountTo value), extend the KCollValidator to provide this functionality and use the resulting subclass instead.
Go up to
Reference