ABLE 2.0.0 07/02/2003 10:25:01

com.ibm.able.rules
Class AblePatternMatchRule

java.lang.Object
  |
  +--com.ibm.able.rules.AbleRule
        |
        +--com.ibm.able.rules.AblePatternMatchRule
All Implemented Interfaces:
java.io.Serializable

public class AblePatternMatchRule
extends AbleRule
implements java.io.Serializable

This class defines a pattern match rule which consists of a set of AbleSelectors (logically ANDed together) and one or more consequent action clauses.

See Also:
AblePatternMatchEngine, AblePatternMatchLiteEngine, Serialized Form

Field Summary
protected  java.util.HashSet myBindings
          myBindings is a vector of vectors.
protected  java.util.Vector myConsequents
          myConsequents is a list of consequent clauses (AbleConsequentClause objects).
protected  java.util.Vector myNetworkSelectors
          myNetworkSelectors is a list of AbleSelectors objects used by the AblePatternMatchEngine (Rete' network).
protected  AblePatternMatchClause myPatternMatchClause
          myPatternMatchClause is an object made from the list of AbleSelector objects.
protected  java.util.Vector mySelectors
          mySelectors is a list of AbleSelectors objects.
protected  com.ibm.able.rules.AblePatternMatchRuleTerminalNode myTerminalNode
          If used with the Rete' net, point to terminal node
 
Fields inherited from class com.ibm.able.rules.AbleRule
myBooleanTruth, myBreakpoint, myComment, myEnabled, myFiredCount, myFiredFlag, myId, myLabel, myLocation, myPreConditions, myPriority, myPrompt, myRdRefs, myRuleSet, myTemplateFlag, myTemplateName, myTemplateValues, myWrRefs, PriorityDefault, RuleIdInitial
 
Constructor Summary
AblePatternMatchRule(java.lang.String theLabel, AbleRd thePriority, java.util.Vector theSelectors, java.util.Vector theConsequents, AbleRuleSet theRuleSet)
          Create a new pattern match rule with the specified priority, selectors, and consequent clauses.
 
Method Summary
 java.lang.String arlString()
          Return a formal Able Rule Language (ARL) String.
 void createNetworkSelectors(AbleRuleSet theRuleSet)
          Create a duplicate set of Selectors, with duplicate expressions as constraints and using duplicate selector variables.
 void createNetworkSelectors2(AbleRuleSet theRuleSet)
          Create a duplicate set of Selectors, with clauses rather than expressions as constraints and using duplicate selector variables.
 java.util.Collection getBindings()
          Retrieve the rule's variable bindings, if any.
 java.util.Vector getDoActions()
          Retrieve the rule's list of "do" action clauses.
 java.util.Vector getNetworkSelectors()
          Retrieve the set of network selectors.
 java.util.Vector getNetworkSelectorVariables()
          Retrieve the set of network selector variables.
 AblePatternMatchClause getPatternMatchClause()
          Retrieve the rule's pattern match clause.
 java.util.Vector getRuleBindings()
          Retrieve the rule's variable bindings, if any.
 java.util.Vector getSelectors()
          Retrieve the rule's list of selector clauses.
 java.util.Vector getSelectorVariables()
          Return a list of selector variables used in this rule
 java.lang.String getTemplateString(java.util.Vector theTemplateVars)
          Retrieve a text format string for use by rule templates.
 boolean isTriggered()
          Returns true if the rule bindings is not an empty set
 long numberOfSelectors()
          Retrieve the number of selector clauses in this rule.
 void removeBindings(java.util.Vector theBindings)
          A set of bindings was used to fire a rule Remove it from the activationList
 void reset()
          Reset the rule to its unfired state.
 void setBindings(java.util.Collection theBindings)
           
 void setBindings(java.util.HashSet theBindings)
          Set the rule's variable bindings, if any.
 void setTerminalNode(com.ibm.able.rules.AblePatternMatchRuleTerminalNode theNode)
           
 java.lang.String toString()
          Retrieve a string describing (the contents of) the object.
 java.lang.String traceString(int theTraceStringFlavor)
          Retrieve a string describing (the contents of) the object.
 java.lang.String xmlString()
          Return a formal XML string.
 
Methods inherited from class com.ibm.able.rules.AbleRule
addHeaderRdReferences, addRdReference, addRdReferences, addWrReference, addWrReferences, arlPreConditionsString, checkTimePeriodPreConditions, clearBreakpoint, Copyright, getArlComment, getBooleanTruth, getBreakpoint, getComment, getId, getIdLabelString, getLabel, getLocation, getPriority, getPrompt, getPromptString, getRdReferences, getTemplateHeaderString, getTemplateName, getTemplateValues, getTemplateVars, getWrReferences, isEnabled, isFired, isGeneratedFromTemplate, isTemplate, logTrace, setBooleanTruth, setBreakpoint, setComment, setEnabled, setFired, setId, setLocation, setPreConditions, setPriority, setPrompt, setTemplate, setTemplateName, setTemplateValues, xmlPreConditionsString, xmlPriorityString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

mySelectors

protected java.util.Vector mySelectors
mySelectors is a list of AbleSelectors objects.

myNetworkSelectors

protected java.util.Vector myNetworkSelectors
myNetworkSelectors is a list of AbleSelectors objects used by the AblePatternMatchEngine (Rete' network). These are created using the createNetworkSelectors() method.

myPatternMatchClause

protected AblePatternMatchClause myPatternMatchClause
myPatternMatchClause is an object made from the list of AbleSelector objects. It is used for efficiency during inferencing.

myBindings

protected java.util.HashSet myBindings
myBindings is a vector of vectors. Each Vector contains a set of references to objects in the working memory that can be bound to the selector variables defined in the selectors. If myBindings.size() > 0 then isTriggered() is true (the rule could fire).

myConsequents

protected java.util.Vector myConsequents
myConsequents is a list of consequent clauses (AbleConsequentClause objects).

myTerminalNode

protected com.ibm.able.rules.AblePatternMatchRuleTerminalNode myTerminalNode
If used with the Rete' net, point to terminal node
Constructor Detail

AblePatternMatchRule

public AblePatternMatchRule(java.lang.String theLabel,
                            AbleRd thePriority,
                            java.util.Vector theSelectors,
                            java.util.Vector theConsequents,
                            AbleRuleSet theRuleSet)
Create a new pattern match rule with the specified priority, selectors, and consequent clauses.
Parameters:
theLabel - The unique label, or name, of this rule.

thePriority - The priority of this rule.

theSelectors - A list of AbleSelector objects that define the selectors (variables and constraints) of this rule. The list is cloned.

theConsequents - A list of AbleConsequentClause objects that define the consequents or actions of this rule.

Method Detail

createNetworkSelectors

public void createNetworkSelectors(AbleRuleSet theRuleSet)
                            throws AbleParException
Create a duplicate set of Selectors, with duplicate expressions as constraints and using duplicate selector variables. These are used in the Rete' network to avoid problems when firing pattern match rules.

createNetworkSelectors2

public void createNetworkSelectors2(AbleRuleSet theRuleSet)
                             throws AbleParException
Create a duplicate set of Selectors, with clauses rather than expressions as constraints and using duplicate selector variables. These are used in the Rete' network to avoid problems when firing pattern match rules.

getNetworkSelectors

public java.util.Vector getNetworkSelectors()
Retrieve the set of network selectors. Note createNetworkSelectors() must be called first.

getNetworkSelectorVariables

public java.util.Vector getNetworkSelectorVariables()
Retrieve the set of network selector variables. Note: createNetworkSelectors() must be called first.

getSelectors

public final java.util.Vector getSelectors()
Retrieve the rule's list of selector clauses.
Returns:
A reference to the actual list of selector clauses. This list may not be empty.

getDoActions

public final java.util.Vector getDoActions()
Retrieve the rule's list of "do" action clauses.
Returns:
A reference to the actual list of do action clauses. This list may not be empty.

numberOfSelectors

public long numberOfSelectors()
Retrieve the number of selector clauses in this rule.
Returns:
A reference to the actual list of selector clauses. This list may be empty (and will be empty if the rule is an assertion rather than a conditional rule), but the list is never null.

getPatternMatchClause

public final AblePatternMatchClause getPatternMatchClause()
Retrieve the rule's pattern match clause.
Returns:
The pattern match clause, comprised of the AbleSelectors used to match data items.

getBindings

public final java.util.Collection getBindings()
Retrieve the rule's variable bindings, if any.
Returns:
The Vector of vectors of variable bindings.

getRuleBindings

public final java.util.Vector getRuleBindings()
Retrieve the rule's variable bindings, if any. and remove them from the rules binding list.
Returns:
The Vector of objects to be bound to variables when firing this rule.

setBindings

public void setBindings(java.util.HashSet theBindings)
Set the rule's variable bindings, if any.
Parameters:
theBindings - The Vector containing sets of valid variable bindings
Returns:
The Vector of vectors of variable bindings. or Vector of tokens containing variable bindings

setBindings

public void setBindings(java.util.Collection theBindings)

removeBindings

public void removeBindings(java.util.Vector theBindings)
A set of bindings was used to fire a rule Remove it from the activationList

setTerminalNode

public void setTerminalNode(com.ibm.able.rules.AblePatternMatchRuleTerminalNode theNode)

getSelectorVariables

public java.util.Vector getSelectorVariables()
Return a list of selector variables used in this rule

isTriggered

public boolean isTriggered()
Returns true if the rule bindings is not an empty set

reset

public void reset()
Reset the rule to its unfired state.
Overrides:
reset in class AbleRule

arlString

public java.lang.String arlString()
Return a formal Able Rule Language (ARL) String.
Overrides:
arlString in class AbleRule
Returns:
A String describing the object in Able rule language.

xmlString

public java.lang.String xmlString()
Return a formal XML string.
Overrides:
xmlString in class AbleRule
Returns:
A String describing the object in XML.

getTemplateString

public java.lang.String getTemplateString(java.util.Vector theTemplateVars)
                                   throws AbleDataException
Retrieve a text format string for use by rule templates. The string contains "{n}" strings, where the index 'n' corresponds to the template variables defined in the rule template. This string is based on the standard arlString() representation of the rule. After replacement of the template variable values, the resulting string must be a valid ARL format string that can be parsed.
Overrides:
getTemplateString in class AbleRule
Parameters:
theTemplateVars - An ordered list of template variables referenced by this rule.
Returns:
A Text format string used to create a new rule instance.
See Also:
AbleRuleTemplate

toString

public java.lang.String toString()
Retrieve a string describing (the contents of) the object.
Overrides:
toString in class AbleRule
Returns:
A String containing the current contents of the object.

traceString

public java.lang.String traceString(int theTraceStringFlavor)
Retrieve a string describing (the contents of) the object.
Overrides:
traceString in class AbleRule
Parameters:
theFlavor - An Able.TraceStringFlavor value.

Returns:
A String containing the current contents of the object.

ABLE 2.0.0 07/02/2003 10:25:01

(C) Copyright IBM Corporation 1999, 2003