An extended data element description is an instance of the ExtendedDataElementDescription
class.
Why and when to perform this task
To add an extended data element description to an event definition,
you must first create a new extended data element description and then set
the values of its fields. You can also add nested (child) extended data element
descriptions, which describe nested extended data elements. You can then add
the extended data element description to the event definition.
Steps for this task
- To create a new extended data element description, create an instance
of ExtendedDataElementDescription, specifying the name and type of the extended
data element.
ExtendedDataElementDescription edeDesc =
new ExtendedDataElementDescription(name, type);
The parameters
of this constructor are as follows:- name
- The name of the extended data element. This must be the value of the name property
of the extended data element you want to describe.
- type
- The data type of the extended data element. This must be one of the following
integer constants defined by the org.eclipse.hyades.logging.events.cbe.ExtendedDataElement
class:
- TYPE_BOOLEAN_ARRAY_VALUE
- TYPE_BOOLEAN_VALUE
- TYPE_BYTE_ARRAY_VALUE
- TYPE_BYTE_ARRAY
- TYPE_DATE_TIME_ARRAY_VALUE
- TYPE_DATE_TIME_VALUE
- TYPE_DOUBLE_ARRAY_VALUE
- TYPE_DOUBLE_VALUE
- TYPE_FLOAT_ARRAY_VALUE
- TYPE_FLOAT_VALUE
- TYPE_HEX_BINARY_VALUE
- TYPE_INT_ARRAY_VALUE
- TYPE_INT_VALUE
- TYPE_LONG_ARRAY_VALUE
- TYPE_LONG_VALUE
- TYPE_NO_VALUE_VALUE
- TYPE_SHORT_ARRAY_VALUE
- TYPE_SHORT_VALUE
- TYPE_STRING_ARRAY_VALUE
- TYPE_STRING_VALUE
The returned object is a new ExtendedDataElementDescription
object.
- Populate the fields of the extended data element description. The ExtendedDataElementDescription class provides a setter method for
each of the fields in an extended data element description. Refer to the Javadoc
API documentation for complete information about these methods. For
example, to specify that an extended data element must occur at least once,
you would set the maxOccurs property to 4 using the
setMaxOccurs(int) method:
edeDesc.setMaxOccurs(4);
- Optional: To add a child extended data element description,
use the ExtendedDataElementDescription.addChild() method.
edeDesc.addChild(childEdeDesc);
The childEdeDesc parameter must be a valid extended data element description.
- Add the extended data element description to the event definition
using the EventDefinition.addExtendedDataElementDescription() method.
definition.addExtendedDataElementDescription(edeDesc);
If
the event definition already includes another extended data element description
with the same name and path, a DescriptionExistsException exception is thrown.
Example
The following code fragment creates a new extended data element description,
populates it with data, and adds it to an event definition.
ExtendedDataElementDescription edeDesc =
new ExtendedDataElementDescription("age", TYPE_SHORT_VALUE);
edeDesc.setMinOccurs(1);
edeDesc.setMaxOccurs(1);
// definition is a valid event definition
definition.addExtendedDataElementDescription(edeDesc);