ABLE 2.3.0 07/13/2005 14:21:00

com.ibm.able.rules
Class AblePlanningRule

java.lang.Object
  extended bycom.ibm.able.rules.AbleRule
      extended bycom.ibm.able.rules.AblePlanningRule
All Implemented Interfaces:
java.io.Serializable
Direct Known Subclasses:
AbleHierarchicalPlanningRule

public class AblePlanningRule
extends AbleRule
implements java.io.Serializable

This class defines a planning rule (action or operator) which consists of a list of parameters (AbleVariables) , a preCondition expression, and effects (one or more consequent clauses).

See Also:
AblePlanningEngine, Serialized Form

Field Summary
protected  java.util.HashSet myBindings
          myBindings is a vector of vectors.
protected  java.util.Vector myEffects
          myEffects is a list of consequent clauses (AbleConsequentClause objects).
protected  java.util.Vector myParameters
          myParameters is a list of AbleVariables representing the formal parameters used by this rule.
protected  AbleExpression myPrecondition
          myPrecondition is an AbleExpression representing the rule preconditon.
 
Fields inherited from class com.ibm.able.rules.AbleRule
myBooleanTruth, myBreakpoint, myComment, myEnabled, myFinalFlag, myFiredCount, myFiredFlag, myId, myLabel, myLocation, myPreConditions, myPriority, myPrompt, myProperties, myRdRefs, myRuleBlock, myRuleSet, myTemplateFlag, myTemplateName, myTemplateValues, myWrRefs, PriorityDefault, RuleIdInitial
 
Constructor Summary
AblePlanningRule(java.lang.String theLabel, AbleRd thePriority, java.util.Vector theParameters, AbleExpression thePrecondition, java.util.Vector theEffects, AbleRuleSet theRuleSet)
          Create a new planning rule with the specified priority, preconditions and effects.
 
Method Summary
 java.lang.String arlString()
          Return a formal Able Rule Language (ARL) String.
 java.lang.String armlString()
          Return a formal XML string.
 java.util.Collection getBindings()
          Retrieve the rule's variable bindings, if any.
 java.util.Vector getEffects()
          Retrieve the rule's list of effect clauses.
 java.util.Vector getParameters()
          Return a list of formal parameter (variables) used in this rule
 AbleExpression getPrecondition()
          Retrieve the rule's precondition expression.
 java.util.Vector getRuleBindings()
          Retrieves the rule's variable bindings, if any, and removes them from the rules binding list.
 java.lang.String getTemplateString(java.util.Vector theTemplateVars)
          Retrieve a text format string for use by rule templates.
 java.util.Vector getVariables()
          Return a list of formal parameter (variables) used in this rule
 boolean isTriggered()
          Returns true if the rule bindings is not an empty set
 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.
 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, arlActionBlockString, arlPreConditionsString, armlPreConditionsString, armlPriorityString, armlPropertiesString, checkTimePeriodPreConditions, clearBreakpoint, getArlComment, getBooleanTruth, getBreakpoint, getComment, getId, getIdLabelString, getLabel, getLocation, getMetaData, getPreConditions, getPriority, getPrompt, getPromptString, getProperties, getProperty, getRdReferences, getTemplateActionBlockString, getTemplateHeaderString, getTemplateName, getTemplateValues, getTemplateVars, getWrReferences, isDefaultPriority, isEnabled, isFinal, isFired, isGeneratedFromTemplate, isTemplate, logTrace, removeProperty, setBooleanTruth, setBreakpoint, setComment, setEnabled, setFinal, setFired, setId, setLocation, setMetaData, setPreConditions, setPriority, setPrompt, setProperties, setProperty, setTemplate, setTemplateName, setTemplateValues, xmlPreConditionsString, xmlPriorityString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myPrecondition

protected AbleExpression myPrecondition
myPrecondition is an AbleExpression representing the rule preconditon.


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).


myEffects

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


myParameters

protected java.util.Vector myParameters
myParameters is a list of AbleVariables representing the formal parameters used by this rule.

Constructor Detail

AblePlanningRule

public AblePlanningRule(java.lang.String theLabel,
                        AbleRd thePriority,
                        java.util.Vector theParameters,
                        AbleExpression thePrecondition,
                        java.util.Vector theEffects,
                        AbleRuleSet theRuleSet)
Create a new planning rule with the specified priority, preconditions and effects.

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

thePriority - The priority of this rule.

theParameters - A list of AbleVariable objects that define the formal parameters of this rule.
thePrecondition - A boolean AbleExpression that defines the necessary precondition of this rule.

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

Method Detail

getPrecondition

public final AbleExpression getPrecondition()
Retrieve the rule's precondition expression.

Returns:
A reference to the precondition expression.

getEffects

public final java.util.Vector getEffects()
Retrieve the rule's list of effect clauses.

Returns:
A reference to the actual list of effect clauses. This list may not be empty.

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()
Retrieves the rule's variable bindings, if any, and removes 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


getParameters

public java.util.Vector getParameters()
Return a list of formal parameter (variables) used in this rule


getVariables

public java.util.Vector getVariables()
Return a list of formal parameter (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.

Specified by:
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.

Specified by:
xmlString in class AbleRule
Returns:
A String describing the object in XML.

armlString

public java.lang.String armlString()
Return a formal XML string.

Specified by:
armlString 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.

Specified by:
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.
Throws:
AbleDataException
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.

Specified by:
traceString in class AbleRule
Parameters:
theTraceStringFlavor - An Able.TraceStringFlavor value.

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

ABLE 2.3.0 07/13/2005 14:21:00

(C) Copyright IBM Corporation 1999, 2005