The following process describes how the toolkit uses typed data elements:
- During the toolkit initialization process, the type externalizer reads
the type definition file and instantiates a concrete instance of DSEType for
each type defined in the type definition file. These type instances have a
default descriptor and a set of 0 or more descriptors that the type externalizer
stores in a table.
- The toolkit does the following things to determine the class name when
creating descriptor instances:
- It checks whether the descriptor has its implClass attribute defined.
- It checks for the class name of the default descriptor of the referred
type. Note that the toolkit can only do this for descriptors that are not
the default descriptor of a type.
- It removes the "Descriptor" suffix from the tag name and appends "PropertyDescriptor".
The system tries to instantiate the resulting class name (which does not have
the package name) using package names defined in the dse.ini file (in the
typedData keyed collection of the packages keyed collection) until it successfully
instantiates the class. The system attempts the instantiation using the order
in which the packages are defined. As a recommendation, packages that contain
descriptors that are used more often should be defined first.
- The toolkit instantiates the typed data elements. The toolkit automatically
instantiates typed data elements belonging to a context when it instantiates
the context. Otherwise, the toolkit instantiates the typed data element in
response to a DSEType readObject static method or the DataElement readObject
method call from the definitions found in the type definition file or the
data definition file.
- The toolkit takes the type reference from the externalizer table and sets
the descriptor attribute of the newly created data element to the default
property descriptor of the date element's type. This prevents the creation
or a new descriptor for each typed data element. All of the typed data elements
share the same descriptor and use a Hashtable of parameters to override the
default attribute values of the default property descriptor. This com.ibm.dse.base.Hashtable
contains a set of key-value pairs in which the key is the name of the attribute
to be overridden and the value is the new value of the attribute.
- The DSETypeExternalizer executes its createDataFromType(Tag aTag) method.
If the tag only overrides the default descriptor's attributes and if the shareDataDescriptors
flag in the dse.ini file is set to true, this method initializes the parameters
attribute of the new data element with the set of attributes defined in the
tag. It then validates the attributes against the descriptor. In this case,
the new data element uses the default descriptor of the referenced type. If
the shareDataDescriptors flag is set to false, this method creates an instance
of the property descriptor and initializes it with the new attributes defined
in the tag.
Once the externalizer has initialized and validated the parameters
attribute and if the shareDataDescriptors flag in the dse.ini file is set
to true, all calls to the data element's property descriptor or to any of
the converters or validators associated with the data element pass the parameters
Hashtable. This enables the toolkit to use the values that are specific to
data element instead of the default ones.
- During the lifetime of the typed data element, if the toolkit is to add
or update data in the typed data element, the toolkit calls the validator
to check the data. The validator first uses the state attribute of the data
element instance to validate the passed Object against the instance. For example,
the validation method does not consider a null value valid if the state attribute
of a data field instance has an active mandatory flag. Once the validate method
considers the Object valid for the state, it calls to the descriptor's validate
method to validate the value according to the type business rules.
If a
validator or converter does not find a specific parameter it needs in the
passed parameters Hashtable, the converter or validator obtains the attribute
values from either the PropertyDescriptor that is also passed or from the
converter's or validator's own Hashtable.