com.ibm.commerce.rule
Class RuleSet

java.lang.Object
  |
  +--com.ibm.commerce.rule.RuleSet
All Implemented Interfaces:
RuleConstants

public class RuleSet
extends java.lang.Object
implements RuleConstants

This class describes a set of rules.


Field Summary
static java.lang.String COPYRIGHT
          Copyright.
 
Fields inherited from interface com.ibm.commerce.rule.RuleConstants
XML_DTD_FRAGMENT, XML_INDENT
 
Constructor Summary
RuleSet(Rule[] rules)
          This constructor takes an array of Rule objects.
 
Method Summary
 Rule[] getRules()
          Gets the array of Rule objects.
 java.lang.String getXMLDocument()
          Gets an XML document that describes this rule set.
 java.lang.String getXMLFragment(java.lang.String indent)
          Gets an XML fragment that describes the rule set.
 void invoke(Evaluator evaluator, ActionHandler actionHandler)
          Invokes the ruleset.
static RuleSet loadRuleSetFromXML(org.w3c.dom.Element element)
          Loads a RuleSet object from an XML element object.
static RuleSet loadRuleSetFromXML(java.lang.String xml)
          Loads a RuleSet object from an XML document.
 void setRules(Rule[] rules)
          Sets the array of Rule objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COPYRIGHT

public static final java.lang.String COPYRIGHT
Copyright.
Constructor Detail

RuleSet

public RuleSet(Rule[] rules)
This constructor takes an array of Rule objects.
Method Detail

getRules

public Rule[] getRules()
Gets the array of Rule objects.
Returns:
An array of Rule objects.

getXMLDocument

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

<!DOCTYPE ruleSet [
<!ELEMENT ruleSet (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 set. This XML fragment will conform to the following DTD fragment:

<!ELEMENT ruleSet (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 fragment.

invoke

public void invoke(Evaluator evaluator,
                   ActionHandler actionHandler)
Invokes the ruleset. All of the rules in the ruleset are invoked.
Parameters:
evaluator - The Evaluator that is used to evaluate the condition.
actionHandler - The ActionHandler that is used to perform the action.

loadRuleSetFromXML

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

loadRuleSetFromXML

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

setRules

public void setRules(Rule[] rules)
Sets the array of Rule objects.
Parameters:
rules - An array of Rule objects.