Attribute instance classes are a means by which you can categorize AttributeInstances. A good analogy is set membership in mathematics. Just as an element can be a member of multiple sets, so can an AttributeInstance belong to multiple classes. You can use an attribute instance’s classes to filter the attributes shown in a decision report, or as selection criteria for obtaining attribute instances from a given EntityInstance.
One important use for Attribute instance classes is to enable filtered retrieval of data items when a session is being saved. For example, an application might define an attribute class “reference” for data that is common to all cases and another class “user_set” for data that is entered by end users. On saving of a session the application would retrieve only the “user_set” attribute instances.
For Oracle an attribute instance class is simply a piece of text that is defined by the application. An AttributeInstance can be associated with a particular class by adding a class to it:
…
…
attributeInstance.addClass(“someClass”);
…
…
Aside from whatever classes an AttributeInstance is explicitly associated to, as shown above, there is also a set of classes that it may be automatically assigned to by Oracle:
At times it may be necessary to determine what classes an AttributeInstance is associated with. To accommodate this Oracle provides a classes() method on AttributeInstance that returns a StringEnumerator over each of the associated classes, as shown in the following example:
classesEnumerator = someAttributeInstance.Classes();
while(classesEnumerator.hasNext())
{
String
attrClass = classesEnumerator.next();
System.out.println(attrClass);
}
Class Discriminators are simple Boolean expressions based around membership of an AttributeInstance to particular classes. The evaluation of a Class Discriminator with respect to any given AttributeInstance can be used by the application programmer to precisely specify which set of AttributeInstances are retrieved from an EntityInstance and those that are to be included in a HowReport.
Class Discriminators may include any of the following operators:
and
or
not
( )
Some examples of class discriminators include:
After defining a Class Discriminator the application programmer can use it to control which AttributeInstances appear in a decision report. The following example shows how an application programmer can generate a decision report that only includes certain AttributeInstances:
…
…
HowReport hr = someAttributeInstance.getHowReport(0,
“not uncertain”);
…
// Process decision report.
As previously stated, Class Discriminators can also be used to select a set of AttributeInstances belonging to a particular group of classes. Following is an example showing the retrieval of all user set AttributeInstances from the global entity instance:
…
…
Rulebase currentRulebase = ...;
Session currentSession = ...;
EntityInstance globalInstance = currentSession.getGlobalEntityInstance();
AttributeInstanceEnumerator userSetAttrInstances
= globalInstance.selectAttributeInstancesByClass(“user”);
…
// Process attribute instance set.
Note:
An empty Class Discriminator (“”) will always evaluate to true when applied
to any AttributeInstance, i.e. match all AttributeInstance.