|
ABLE 2.0.0 07/02/2003 10:25:01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--com.ibm.able.rules.AbleRuleBlock
This class represents a named set of rules, an associated inference engine, and a return data type. Ruleblocks are used to partition rulesets into groups which are processed by an inference engine to produce some result.
There are several "special" ruleblocks with reserved names, such as init(), preProcess(), process(), postProcess(), handleTimerEvent(), handleAbleEvent(), catch(), and quitAll(). These ruleblocks are processed at specific times in the life of an AbleRuleSet bean.
Other named ruleblocks can be invoked using the invokeRuleBlock("name") built-in function. Ruleblocks can return no value (void) or they can return values to the caller using the returnFromRuleBlock(value) built-in function.
Field Summary | |
---|---|
protected java.util.Vector |
myAstRuleList
myAstRuleList is the sequence of assertion rules in this rule block. |
protected java.util.Vector |
myCndRuleList
myCndRuleList is the sequence of conditional rules in this rule block. |
protected java.lang.String |
myComment
"myComment" provides a place to associate a comment with this rule block. |
protected java.util.Hashtable |
myControlParameterList
The parameters used to control the associated inference engine |
protected java.util.Vector |
myControlParameters
|
protected java.lang.String |
myEngineType
The type of inference engine to be used to evaluate the rules in this ruleblock |
protected java.util.Vector |
myIfThenElseRuleList
myIfThenElseRuleList is the sequence of if (expr) then-else rules in this rule block. |
protected AbleInferenceEngine |
myInferenceEngine
The inference engine associated with this ruleblock |
protected java.util.Vector |
myIterationRuleList
myIterationRuleList is the sequence of iteration rules in this rule block. |
protected java.lang.String |
myName
myName is the unique name of this particular rule block; that is, each rule block within an AbleRuleSet must have a unique name. |
protected java.util.Vector |
myPatternMatchRuleList
myPatternMatchRuleList is the sequence of pattern match rules in this rule block. |
protected java.util.Vector |
myPredicateRuleList
myPredicateRuleList is the sequence of predicate facts and rules in this rule block. |
protected boolean |
myProcessedFlag
myProcessedFlag indicates whether this rule block has been processed at least once. |
protected java.lang.String |
myReturnType
The rule block return type (for example "String") |
protected java.lang.Object |
myReturnValue
The return value from this ruleblock reset to null on entry, only set if user codes a return() statement |
protected java.util.Vector |
myRuleList
myRuleList is the sequence of all rules that make up this rule block. |
protected AbleRuleSet |
myRuleSet
The parent ruleset |
protected AbleLogger |
myTrace
The inference engine trace logger |
static java.lang.String |
RuleBlockCatch
Rule Block Name: Catch |
static java.lang.String |
RuleBlockInit
Rule Block Name: Init |
static java.lang.String |
RuleBlockPostProcess
Rule Block Name: PostProcess |
static java.lang.String |
RuleBlockPreProcess
Rule Block Name: PreProcess |
static java.lang.String |
RuleBlockProcess
Rule Block Name: Process |
static java.lang.String |
RuleBlockProcessAbleEvent
Rule Block Name: ProcessAbleEvent |
static java.lang.String |
RuleBlockProcessTimerEvent
Rule Block Name: ProcessTimerEvent |
static java.lang.String |
RuleBlockQuitAll
Rule Block Name: QuitAll |
Constructor Summary | |
---|---|
AbleRuleBlock(java.lang.String theName,
AbleRuleSet theRuleSet,
AbleLogger theLogger,
java.lang.String theReturnType)
Create a new rule block with the specified name. |
Method Summary | |
---|---|
protected void |
addAssertion(AbleAssertionRule theRule)
Add an assertion to the rule block. |
protected void |
addConditionalRule(AbleConditionalRule theRule)
Add a conditional (if-then) rule to the rule block. |
protected void |
addIfThenElseRule(AbleIfThenElseRule theRule)
Add an if (expr) then-else rule to the rule block. |
protected void |
addIterationRule(AbleIterationRule theRule)
Add an iteration rule (do/while, do/until, while/do, for-loop) to the rule block. |
protected void |
addPatternMatchRule(AblePatternMatchRule theRule)
Add a pattern match (when-do) rule to the rule block. |
protected void |
addPredicateRule(AblePredicateRule theRule)
Add a predicate fact or rule to the rule block. |
protected void |
addRule(AbleRule theRule)
Add an Able rule (any type) to the end of the rule block. |
java.lang.String |
arlString()
Return a formal Able Rule Language (ARL) String. |
void |
checkTimePeriodPreConditions(java.util.Calendar theCurrentTime)
Evaluate each rule in the ruleblock against the time period preconditions. |
static java.lang.String |
Copyright()
Determine the copyright of this class. |
java.lang.String |
getArlComment()
Retrieve the comment associated with this ruleblock as an arl string enclosed in javadoc delimeters. |
java.util.Vector |
getAssertions()
Retrieve the list of assertion rules. |
java.lang.String |
getComment()
Retrieve the comment associated with this ruleblock. |
java.util.Vector |
getConditionalRules()
Retrieve the list of conditional rules. |
java.lang.Object |
getControlParameter(java.lang.String theControlParameter)
Returns a single control parameter on the associated inference engine. |
java.util.Hashtable |
getControlParameters()
Retrieve the (possibly empty) set of parameters passed to the associated inference engine. |
java.util.Vector |
getEnabledAssertions()
Retrieve the list of enabled assertion rules. |
java.util.Vector |
getEnabledConditionalRules()
Retrieve the list of enabled conditional rules. |
java.util.Vector |
getEnabledIfThenElseRules()
Retrieve the list of enabled if-then-else rules. |
java.util.Vector |
getEnabledIterationRules()
Retrieve the list of enabled iteration rules. |
java.util.Vector |
getEnabledPatternMatchRules()
Retrieve the list of enabled pattern match rules. |
java.util.Vector |
getEnabledPredicateRules()
Retrieve the list of enabled predicate facts and rules. |
java.util.Vector |
getEnabledRules()
Retrieve the list of all enabled rules. |
java.lang.String |
getEngineType()
Retrieve the current engine type. |
java.util.Vector |
getIfThenElseRules()
Retrieve the list of if-then-else rules. |
AbleInferenceEngine |
getInferenceEngine()
Retrieve the rule block's inference engine. |
java.util.Vector |
getIterationRules()
Retrieve the list of iteration rules. |
java.lang.String |
getName()
Retrieve the rule block's unique name. |
java.util.Vector |
getPatternMatchRules()
Retrieve the list of pattern match rules. |
java.util.Vector |
getPredicateRules()
Retrieve the list of predicate facts and rules. |
java.lang.String |
getReturnType()
Retrieve the return data type of this ruleblock |
java.lang.Object |
getReturnValue()
Retrieve the return value (if any) set on this ruleblock |
java.util.Vector |
getRules()
Retrieve the list of all rules. |
int |
getRulesFiredCount()
Returns the number of rules fired by the associated inference engine during the last infer() call |
java.util.Vector |
getRuleTemplates()
Retrieve all rule template objects defined in this ruleblock |
java.lang.String |
getTemplateString(java.util.Vector theTemplateVars)
Retrieve a text format string for use by ruleset templates. |
java.util.Vector |
getTemplateVars(AbleRuleSet theRuleSet)
Return a list of template vars referenced by this ruleblock. |
AbleWorkingMemory |
getWorkingMemory()
Retrieve the working memory associated with the rule block's inference engine. |
void |
init()
Initialize and configure the ruleblock by dynamically creating an instance of the specified inference engine. |
protected void |
insertRuleAt(int theIndex,
AbleRule theRule)
Insert an Able rule (any type) at specified position in the rule block. |
boolean |
isProcessed()
Determine whether this rule block has been processed at least once. |
void |
process()
|
protected void |
removeRule(AbleRule theRule)
Remove an Able rule (any type) from the rule block. |
protected void |
replaceRule(AbleRule theOldRule,
AbleRule theNewRule)
Replace an Able rule (any type) in the rule block at its current position in the ruleblock. |
void |
reset()
Reset the rule block so that rules can be fired again: all rules are set to their original state. |
void |
setComment(java.lang.String theComment)
Set (or change) the comment associated with this ruleblock. |
void |
setControlParameter(java.lang.String theControlParameter,
java.lang.Object theValue)
Set a single control parameter on the associated inference engine. |
void |
setControlParameters(java.util.Hashtable theControlParameters)
Set the (possibly empty) set of parameters passed to the associated inference engine. |
void |
setDebugLevel(int theDebugLevel)
Set the debug level on the associated inference engine |
void |
setEngineType(java.lang.String theEngineType)
Set the type of the inference engine to be used by this ruleblock Note: the name must be registered with the AbleRuleSet and the engine class must be accessible via the CLASSPATH. |
void |
setProcessed(boolean theProcessedFlag)
Set the flag that indicates whether this rule block has been processed at least once. |
void |
setReturnValue(java.lang.Object theReturnValue)
Set the return value for this ruleblock |
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 java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final java.lang.String RuleBlockInit
The "init" rule block is processed once when the AbleRuleSet init() method is invoked.
public static final java.lang.String RuleBlockProcess
The "process" rule block is meant to be processed multiple times, once for each "process" cycle, and it is meant to be processed by a specialized inference engine, such as a fuzzy logic inference engine or a bollean forward chainer. The rules are processed in an order determined by the inference engine.
public static final java.lang.String RuleBlockPreProcess
The "preProcess" rule block is meant to be called before the process() rule block is called.
public static final java.lang.String RuleBlockPostProcess
The "postProcess" rule block is meant to be processed each time processing of the process() rule block quiesces.
public static final java.lang.String RuleBlockCatch
The "catch" rule block is called to handle exceptions that are thrown during the evaluation of the process() method.
public static final java.lang.String RuleBlockQuitAll
The "finally" rule block is called when the bean quitAll() method is invoked.
public static final java.lang.String RuleBlockProcessTimerEvent
The "processTimerEvent" rule block is called to process timer events generated by the ruleset bean.
public static final java.lang.String RuleBlockProcessAbleEvent
The "processAbleEvent" rule block is called to process able events received by the ruleset bean due to a handleAbleEvent() (or processAbleEvent()) method invocation. The rules can access the event object via the "event" built-in variable.
protected java.lang.String myName
protected AbleInferenceEngine myInferenceEngine
protected java.util.Vector myRuleList
protected java.util.Vector myAstRuleList
protected java.util.Vector myCndRuleList
protected java.util.Vector myIfThenElseRuleList
protected java.util.Vector myPatternMatchRuleList
protected java.util.Vector myPredicateRuleList
protected java.util.Vector myIterationRuleList
protected boolean myProcessedFlag
This flag is not reset by the reset() method.
protected java.lang.String myEngineType
protected AbleRuleSet myRuleSet
protected AbleLogger myTrace
protected java.util.Hashtable myControlParameterList
protected java.util.Vector myControlParameters
protected java.lang.String myReturnType
protected java.lang.Object myReturnValue
protected java.lang.String myComment
setComment(String)
,
getComment()
Constructor Detail |
public AbleRuleBlock(java.lang.String theName, AbleRuleSet theRuleSet, AbleLogger theLogger, java.lang.String theReturnType)
theName
- The unique name of this rule block.
Method Detail |
public void init() throws AbleException, AbleParException, AbleDataException
public void process() throws AbleDataException
public final void checkTimePeriodPreConditions(java.util.Calendar theCurrentTime) throws AbleDataException
public final void setDebugLevel(int theDebugLevel)
public java.util.Hashtable getControlParameters()
public void setControlParameters(java.util.Hashtable theControlParameters) throws AbleDataException
public void setControlParameter(java.lang.String theControlParameter, java.lang.Object theValue) throws AbleDataException
public java.lang.Object getControlParameter(java.lang.String theControlParameter) throws AbleDataException
public void setReturnValue(java.lang.Object theReturnValue)
public java.lang.Object getReturnValue()
public java.lang.String getReturnType()
public java.lang.String getName()
public void setComment(java.lang.String theComment)
theComment
- A String containing the new comment for this ruleblock.
This comment replaces the current comment.
myComment
public java.lang.String getComment()
myComment
public java.lang.String getArlComment()
myComment
public AbleInferenceEngine getInferenceEngine()
public AbleWorkingMemory getWorkingMemory()
public void setEngineType(java.lang.String theEngineType)
public final java.lang.String getEngineType()
AbleRuleSet
class.setEngineType(java.lang.String)
protected void addAssertion(AbleAssertionRule theRule)
theRule
- The assertion to add.
protected void addConditionalRule(AbleConditionalRule theRule)
theRule
- The conditional rule to add.
protected void addIfThenElseRule(AbleIfThenElseRule theRule)
theRule
- The if-then-else rule to add.
protected void addPatternMatchRule(AblePatternMatchRule theRule)
theRule
- The pattern match rule to add.
protected void addPredicateRule(AblePredicateRule theRule)
theRule
- The predicate fact or rule to add.
protected void addIterationRule(AbleIterationRule theRule)
theRule
- The rule to add.
protected void addRule(AbleRule theRule)
theRule
- The rule to add.
protected void insertRuleAt(int theIndex, AbleRule theRule)
theRule
- The rule to add.theIndex
- the integer position or index where the rule should be inserted (0-based)
protected void removeRule(AbleRule theRule)
theRule
- The rule to remove.
protected void replaceRule(AbleRule theOldRule, AbleRule theNewRule)
theRule
- The rule to be replaced.
public java.util.Vector getRules()
public java.util.Vector getEnabledRules()
public java.util.Vector getAssertions()
public java.util.Vector getEnabledAssertions()
public java.util.Vector getConditionalRules()
public java.util.Vector getEnabledConditionalRules()
public java.util.Vector getIfThenElseRules()
public java.util.Vector getEnabledIfThenElseRules()
public java.util.Vector getPatternMatchRules()
public java.util.Vector getEnabledPatternMatchRules()
public java.util.Vector getPredicateRules()
public java.util.Vector getEnabledPredicateRules()
public java.util.Vector getIterationRules()
public java.util.Vector getEnabledIterationRules()
public java.lang.String arlString()
public java.lang.String xmlString()
public void reset()
public void setProcessed(boolean theProcessedFlag)
theProcessedFlag
- Use true to indicate that the rules in this
rule block have been processed at least once;
use false otherwise.public boolean isProcessed()
public java.util.Vector getRuleTemplates() throws AbleDataException
public java.lang.String getTemplateString(java.util.Vector theTemplateVars) throws AbleDataException
theTemplateVars
- An ordered list of template variables referenced by this ruleblock.AbleRuleTemplate
public java.util.Vector getTemplateVars(AbleRuleSet theRuleSet) throws AbleDataException
public int getRulesFiredCount()
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String traceString(int theTraceStringFlavor)
theFlavor
- An Able.TraceStringFlavor value.
public static java.lang.String Copyright()
|
ABLE 2.0.0 07/02/2003 10:25:01 | ||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |