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

com.ibm.able.rules
Class AblePredicateRule

java.lang.Object
  |
  +--com.ibm.able.rules.AbleRule
        |
        +--com.ibm.able.rules.AblePredicateRule
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AblePredicateFact

public class AblePredicateRule
extends AbleRule
implements java.io.Serializable

This class represents a predicate rule (or Horn clause) containing one or more antecedent clauses (logically ANDed together) (the body) and one and only one predicate consequent clause (the head).

See Also:
Serialized Form

Field Summary
protected static int copyId
           
protected  java.util.Vector myAntecedents
          myAntecedents is a list of AbleAntecedentClause objects.
protected  AblePredicate myConsequent
          myConsequent is a single predicate clause or head of the rule.
protected  java.util.Vector myCuts
          Vector of cut() predicates in the antecedent list (null if none)
protected  java.util.Vector myVariables
          myVariables is a list of all of the AbleVariable objects that appear in the rule (body and head).
 
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
AblePredicateRule(int theId, java.lang.String theLabel, AbleRd thePriority, AbleRuleSet theRuleSet)
          Create a new predicate fact with the specified id, label, priority, and tracer
AblePredicateRule(int theId, java.lang.String theLabel, AbleRd thePriority, java.util.Vector theAntecedents, AblePredicate theConsequent, AbleRuleSet theRuleSet)
          Create a new predicate rule with the specified priority, antecedent clauses, and consequent clause.
AblePredicateRule(int theId, java.lang.String theLabel, java.util.Vector theAntecedents, AblePredicate theConsequent, AbleRuleSet theRuleSet)
          Create a new predicate rule with the specified antecedent clauses and consequent clause.
AblePredicateRule(java.lang.String theLabel, AbleRd thePriority, java.util.Vector theAntecedents, AblePredicate theConsequent, AbleRuleSet theRuleSet)
          Create a new predicate rule with the specified priority, antecedent clauses, and consequent clause.
AblePredicateRule(java.lang.String theLabel, java.util.Vector theAntecedents, AblePredicate theConsequent, AbleRuleSet theRuleSet)
          Create a new predicate rule with the specified antecedent clauses and consequent clause.
 
Method Summary
 void applyBindings(java.util.Vector bindings)
           
 java.lang.String arlString()
          Return a formal Able Rule Language (ARL) String.
 AblePredicateRule createMatchRule()
          Create a duplicate of this rule with new variables
 void displayBindings(java.util.Vector bindings)
           
protected  void findAllVariables()
          Find all variables that appear in this rule Also looks for any cut() predicates in the antecedent clauses
 java.util.Vector getAntecedents()
          Retrieve the rule's list of antecedent clauses.
 java.util.Vector getBindings()
          Create a Vector of all variables and their current values
 AblePredicate getConsequent()
          Retrieve the rule's consequent clause, if any.
 java.util.Vector getCuts()
          Retrieves a list of cut() predicates (if any), null (if none)
 java.lang.String getSignature()
          Returns the signature of the rule head (consequent)
 java.lang.String getTemplateString(java.util.Vector theTemplateVars)
          Retrieve a text format string for use by rule templates.
 long numberOfAntecedents()
          Retrieve the number of antecedent clauses in this rule.
 void reset()
          Reset the rule to its unfired state.
 void resetAllVariables()
          Clear all variables
 void setBindings(java.util.Vector bindings)
          Apply these bindings to this rule Bindings are Variable-Value pairs
 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.
protected  java.lang.String trcString(int theTraceStringFlavor)
           
 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

copyId

protected static int copyId

myAntecedents

protected java.util.Vector myAntecedents
myAntecedents is a list of AbleAntecedentClause objects. If clauses are present, along with a consequent clause, this rule is a predicate rule, and the assertion clause must be null.

myConsequent

protected AblePredicate myConsequent
myConsequent is a single predicate clause or head of the rule.

myVariables

protected java.util.Vector myVariables
myVariables is a list of all of the AbleVariable objects that appear in the rule (body and head).

myCuts

protected java.util.Vector myCuts
Vector of cut() predicates in the antecedent list (null if none)
Constructor Detail

AblePredicateRule

public AblePredicateRule(java.lang.String theLabel,
                         java.util.Vector theAntecedents,
                         AblePredicate theConsequent,
                         AbleRuleSet theRuleSet)
Create a new predicate rule with the specified antecedent clauses and consequent clause. The rule will have a default priority.
Parameters:
theLabel - The unique label, or name, of this rule.

theAntecedents - A list of AbleAntecedentClause objects that define the antecedents of this rule. The list is cloned.

theConsequent - A single assignment statement that defines the consequent of this rule.

theRuleSet - The ruleset object this rule belongs to.

AblePredicateRule

public AblePredicateRule(java.lang.String theLabel,
                         AbleRd thePriority,
                         java.util.Vector theAntecedents,
                         AblePredicate theConsequent,
                         AbleRuleSet theRuleSet)
Create a new predicate rule with the specified priority, antecedent clauses, and consequent clause.
Parameters:
theLabel - The unique label, or name, of this rule.

thePriority - The priority of this rule.

theAntecedents - A list of AbleAntecedentClause objects that define the antecedents of this rule. The list is cloned.

theConsequent - A single assignment statement that defines the consequent of this rule.

theRuleSet - The ruleset object this rule belongs to.

AblePredicateRule

public AblePredicateRule(int theId,
                         java.lang.String theLabel,
                         java.util.Vector theAntecedents,
                         AblePredicate theConsequent,
                         AbleRuleSet theRuleSet)
Create a new predicate rule with the specified antecedent clauses and consequent clause. The rule will have a default priority.
Parameters:
theId - The unique Id of this rule.

theLabel - The unique label, or name, of this rule.

theAntecedents - A list of AbleAntecedentClause objects that define the antecedents of this rule. The list is cloned.

theConsequent - A single assignment statement that defines the consequent of this rule.

theRuleSet - A ruleset object to which this rule belongs.


AblePredicateRule

public AblePredicateRule(int theId,
                         java.lang.String theLabel,
                         AbleRd thePriority,
                         java.util.Vector theAntecedents,
                         AblePredicate theConsequent,
                         AbleRuleSet theRuleSet)
Create a new predicate rule with the specified priority, antecedent clauses, and consequent clause.
Parameters:
theId - The unique Id of this rule.

theLabel - The unique label, or name, of this rule.

thePriority - The priority of this rule. (ignored by predicate engine)

theAntecedents - A list of AbleAntecedentClause objects that define the antecedents of this rule. The list is cloned.

theConsequent - A single assignment statement that defines the consequent of this rule.

theRuleSet - A ruleset object to which this rule belongs.


AblePredicateRule

public AblePredicateRule(int theId,
                         java.lang.String theLabel,
                         AbleRd thePriority,
                         AbleRuleSet theRuleSet)
Create a new predicate fact with the specified id, label, priority, and tracer
Parameters:
theId - The unique Id of this rule.

theLabel - The unique label, or name, of this rule.

thePriority - The priority of this rule.

theRuleSet - A ruleset object to which this rule belongs.

Method Detail

createMatchRule

public AblePredicateRule createMatchRule()
Create a duplicate of this rule with new variables

findAllVariables

protected void findAllVariables()
Find all variables that appear in this rule Also looks for any cut() predicates in the antecedent clauses

getAntecedents

public java.util.Vector getAntecedents()
Retrieve the rule's list of antecedent clauses.
Returns:
A reference to the actual list of antecedent 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.

numberOfAntecedents

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

getConsequent

public AblePredicate getConsequent()
Retrieve the rule's consequent clause, if any.
Returns:
The consequent clause (head) of the rule

getSignature

public java.lang.String getSignature()
Returns the signature of the rule head (consequent)

reset

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

getCuts

public java.util.Vector getCuts()
Retrieves a list of cut() predicates (if any), null (if none)

resetAllVariables

public void resetAllVariables()
Clear all variables

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.

setBindings

public void setBindings(java.util.Vector bindings)
                 throws AbleDataException
Apply these bindings to this rule Bindings are Variable-Value pairs

getBindings

public java.util.Vector getBindings()
                             throws AbleDataException
Create a Vector of all variables and their current values

applyBindings

public void applyBindings(java.util.Vector bindings)
                   throws AbleDataException

displayBindings

public void displayBindings(java.util.Vector bindings)
                     throws AbleDataException

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.

trcString

protected java.lang.String trcString(int theTraceStringFlavor)

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

(C) Copyright IBM Corporation 1999, 2003