previous chapter contents page top page next chapter

RuleQualifier

February 14, 1995
Defined in Rule.Def

Inherits from Object

Inherits interface from PeopleListTarget


Class Description

Some rules don't take effect every time they're triggered. Instead, they must meet an additional qualification, described by an object of class RuleQualifier. The qualification test is implemented by the QualifyRule method of class RuleQualifier.

Remember that if the documentation and the software (especially the definition files) disagree, always trust the software.

Programming Information

Instantiate: never
Subclass: always
Call its methods: rarely

Class RuleQualifier is a framework for qualifiers. Most of its methods don't do anything. Instead of using class RuleQualifier, you should use one of its subclasses, such as LocalRuleQualifier or SimpleMessageQualifier. Class RuleQualifier has another subclass, class ServiceMessageQualifier, that you're not likely to use unless you're writing rules for a new mail service. You could also use the information in this chapter to create your own subclass of RuleQualifier if the existing subclasses don't meet your needs.

Methods you might call

Class RuleQualifier defines the following methods:

Method Description
QualifyRule Check to see if the rule meets its qualification (returns true by default)
ComputeRuleText Create a text description for the rule, using the qualifier (does nothing by default)
PrepareEditControl Set up the controls that edit the qualifier's entity (does nothing by default)
SetEntity Set the entity associated with this qualifier (does nothing by default)
EditStepsForNewEntity Return the steps to edit an entity associated with this qualifier (returns
nilObject by default)

Methods you must override

When you create a subclass of class RuleQualifier, you must override these methods:

Method Override to
ComputeRuleText If you want to compute a special text description for the rule using the qualifier
QualifyRule If you want to test whether a rule's conditions have been met

Description of fields

Class RuleQualifier defines no fields.

Method Descriptions

QualifyRule

operation QualifyRule(contextObject: Object; rule: Object): Boolean
call: rarely
override: always

The systems calls QualifyRule in the process of deciding if a rule's action should take place. See the chapter on class Rule for the details on exactly how the system calls this method. Class RuleQualifier does not implement QualifyRule. If you create a subclass, you must override this method.

Here's how the system will call QualifyRule:

qualified = QualifyRule(qualifier, triggerData, rule);

The triggerData parameter is the original trigger data passed to PostTrigger. QualifyRule should return true if the rule meets its qualification. What qualification means is entirely defined by you in your implementation of the method.

Our example class GizmoRuleQualifier defines QualifyRule this way:

Method Boolean
GizmoRuleQualifier_QualifyRule(ObjectID self, long triggerData, ObjectID rule)
    {
    Boolean     qualified = false;
    ObjectID    triggerObject = (ObjectID)triggerData;
    /* make sure we can use trigger object as a frobber */
    if (triggerObject) 
        qualified = CanFrobWith(triggerObject);
    return qualified;
    }

ComputeRuleText

operation ComputeRuleText(rule: Rule; mapping: Object);
call: rarely
override: always

The system calls ComputeRuleText while updating a rule's text for display in a rule view. It calls this method from Rule_UpdateText, immediately before calling ComputeRuleText on the rule's action. RuleQualifier_ ComputeRuleText does nothing. Override ComputeRuleText if you intend to use your custom rule action with editable rules.

ComputeRuleText should replace lines in the text object passed in the mapping parameter with the appropriate text.

For an example of how you might implement ComputeRuleText, see the chapter on class LocalRuleQualifier. The description of LocalRuleQualifier_ ComputeRuleText includes a complete sample implementation.