com.ibm.commerce.rule

Class Rule

  • java.lang.Object
    • com.ibm.commerce.rule.Rule
  • All Implemented Interfaces:
    RuleConstants, com.ibm.websphere.cache.Sizeable, java.io.Serializable


    public final class Rule
    extends java.lang.Object
    implements RuleConstants, java.io.Serializable, com.ibm.websphere.cache.Sizeable
    This class binds a condition to an action. It also contains methods that help convert a rule to and from XML format.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor and Description
      Rule(Condition condition, Action action)
      This constructor takes a Condition object and an Action object.
    • Field Detail

      • COPYRIGHT

        public static final java.lang.String COPYRIGHT
        IBM copyright notice field.
        See Also:
        Constant Field Values
    • Constructor Detail

      • Rule

        public Rule(Condition condition,
                    Action action)
        This constructor takes a Condition object and an Action object.
        Parameters:
        condition - The Condition object that is used in this rule.
        action - The Action object that is used in this rule.
    • Method Detail

      • getObjectSize

        public long getObjectSize()
        Returns the estimated footprint size in bytes of this object and the objects it contains.
        Specified by:
        getObjectSize in interface com.ibm.websphere.cache.Sizeable
        Returns:
        the estimated footprint size in bytes or -1 if a size cannot be determined.
      • getCondition

        public Condition getCondition()
        Gets the condition for this rule.
        Returns:
        A Condition object.
      • setCondition

        public void setCondition(Condition condition)
        Sets the condition for this rule.
        Parameters:
        condition - A Condition object.
      • getAction

        public Action getAction()
        Gets the action for this rule.
        Returns:
        An Action object.
      • setAction

        public void setAction(Action action)
        Sets the action for this rule.
        Parameters:
        action - An Action object.
      • getComment

        public java.lang.String getComment()
        Gets the comment for this rule.
        Returns:
        A comment string.
      • setComment

        public void setComment(java.lang.String comment)
        Sets the comment for this rule.
        Parameters:
        comment - A comment string.
      • invoke

        public void invoke(Evaluator evaluator,
                           ActionHandler handler)
        Invoke the rule. If the condition evaluates to true, then the action is performed.
        Parameters:
        evaluator - The Evaluator that is used to evaluate the condition.
        handler - The ActionHandler that is used to perform the action.
      • getXMLDocument

        public java.lang.String getXMLDocument()
        Gets an XML document that describes this rule. The XML document will conform to the following DTD:

        <!DOCTYPE rule [
        <!ELEMENT rule (comment?, (orListCondition | andListCondition | simpleCondition | trueCondition | openCondition), action)>
        <!ELEMENT comment EMPTY>
        <!ATTLIST comment text CDATA #REQUIRED>
        <!ELEMENT action (parameter*)>
        <!ATTLIST action name CDATA #REQUIRED>
        <!ELEMENT orListCondition (not?, (orListCondition | andListCondition | simpleCondition | trueCondition | openCondition)+)>
        <!ELEMENT andListCondition (not?, (orListCondition | andListCondition | simpleCondition | trueCondition | openCondition)+)>
        <!ELEMENT simpleCondition (not?, variable, operator, value, qualifier*)>
        <!ELEMENT openCondition (not?, parameter*)>
        <!ATTLIST openCondition name CDATA #REQUIRED>
        <!ELEMENT trueCondition (not?)>
        <!ELEMENT not EMPTY>
        <!ELEMENT variable EMPTY>
        <!ATTLIST variable name CDATA #REQUIRED>
        <!ELEMENT operator EMPTY>
        <!ATTLIST operator name CDATA #REQUIRED>
        <!ELEMENT value EMPTY>
        <!ATTLIST value data CDATA #REQUIRED>
        <!ELEMENT qualifier EMPTY>
        <!ATTLIST qualifier name CDATA #REQUIRED>
        <!ATTLIST qualifier data CDATA #REQUIRED>
        <!ELEMENT parameter (parameter*)>
        <!ATTLIST parameter name CDATA #REQUIRED>
        <!ATTLIST parameter value CDATA #REQUIRED>
        ]>

        Returns:
        An XML document.
      • getXMLFragment

        public java.lang.String getXMLFragment(java.lang.String indent)
        Gets an XML fragment that describes the rule. This XML fragment will conform to the following DTD fragment:

        <!ELEMENT rule (comment?, (orListCondition | andListCondition | simpleCondition | trueCondition | openCondition), action)>
        <!ELEMENT comment EMPTY>
        <!ATTLIST comment text CDATA #REQUIRED>
        <!ELEMENT action (parameter*)>
        <!ATTLIST action name CDATA #REQUIRED>
        <!ELEMENT orListCondition (not?, (orListCondition | andListCondition | simpleCondition | trueCondition | openCondition)+)>
        <!ELEMENT andListCondition (not?, (orListCondition | andListCondition | simpleCondition | trueCondition | openCondition)+)>
        <!ELEMENT simpleCondition (not?, variable, operator, value, qualifier*)>
        <!ELEMENT openCondition (not?, parameter*)>
        <!ATTLIST openCondition name CDATA #REQUIRED>
        <!ELEMENT trueCondition (not?)>
        <!ELEMENT not EMPTY>
        <!ELEMENT variable EMPTY>
        <!ATTLIST variable name CDATA #REQUIRED>
        <!ELEMENT operator EMPTY>
        <!ATTLIST operator name CDATA #REQUIRED>
        <!ELEMENT value EMPTY>
        <!ATTLIST value data CDATA #REQUIRED>
        <!ELEMENT qualifier EMPTY>
        <!ATTLIST qualifier name CDATA #REQUIRED>
        <!ATTLIST qualifier data CDATA #REQUIRED>
        <!ELEMENT parameter (parameter*)>
        <!ATTLIST parameter name CDATA #REQUIRED>
        <!ATTLIST parameter value CDATA #REQUIRED>

        Returns:
        An XML fragment.
      • loadRuleFromXML

        public static Rule loadRuleFromXML(java.lang.String xml)
        Loads a Rule object from an XML document.
        Parameters:
        xml - An XML document.
        Returns:
        A Rule object that matches the XML.
      • loadRuleFromXML

        public static Rule loadRuleFromXML(org.w3c.dom.Element element)
        Loads a Rule object from an XML element object.
        Parameters:
        element - An XML Element object.
        Returns:
        A Rule object that matches the XML.