A property description is an instance of the class PropertyDescription.
Why and when to perform this task
To add a property description to an event definition, you must first
create a new property description and then set the values of its fields. You
can then add the property description to the event definition.
Steps for this task
- To create a new property description, create an instance of PropertyDescription,
specifying the name and path of the property.
PropertyDescription propDesc = new PropertyDescription(name, path);
The parameters of this constructor are as follows:- name
- The name of the property. This must be the name of a simple property either
of the CommonBaseEvent element or one of its children.
- path
- An XPath location path specifying the path to the property. For a top-level
property of CommonBaseEvent (such as severity or priority), path should
be null.
The returned object is a new PropertyDescription
object.
- Populate the fields of the property description. The
PropertyDescription class provides a setter method for each of the fields
in a property description. Refer to the Javadoc API documentation for complete
information about these methods. For example, to specify that
a property is required, you would set the required property to true using
the setRequired(boolean) method:
propDesc.setRequired(true);
- Add the property description to the event definition using the
EventDefinition.addPropertyDescription() method.
definition.addPropertyDescription(propDesc);
If
the event definition already includes another property description with the
same name and path, a DescriptionExistsException exception is thrown.
Example
The following code fragment creates a new property description, populates
it with data, and adds it to an event definition.
PropertyDescription propDesc = new PropertyDescription("severity",null);
propDesc.setRequired(true);
propDesc.setMinValue('30');
// definition is a valid event definition
definition.addPropertyDescription(propDesc);