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

com.ibm.able.rules
Class AbleAntecedentClause

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

public class AbleAntecedentClause
extends AbleClause
implements java.io.Serializable

This class is used to represent an antecedent boolean or fuzzy expression in a conditional if-then rule. When evaluated using boolean logic, an antecedent clause can return one of three values as its truth value: true, false, and null, which is the case if either of the clause's arguments is null. Each time an antecedent clause is evaluated in boolean logic, the truth value is cached. This helps prevent the clause from being re-valuated unnecessarily.

When evaluated in fuzzy logic, a fuzzy truth value is returned, which may be influenced by the clause's weight.

See Also:
Serialized Form

Field Summary
static double ClauseWeightDefault
          A default weight.
protected  java.lang.Boolean myBooleanTruth
          myBooleanTruth contains the current truth value of this clause, but only if the clause has been evaluated.
protected  double myClauseWeight
          myClauseWeight represents the weight that this clause is to assume when the clause is evaluated.
 
Fields inherited from class com.ibm.able.rules.AbleClause
myLhs, myOp, myRhs, myRuleRefs
 
Constructor Summary
AbleAntecedentClause(AbleExpression theExpression)
          Create a new clause from the specified expression.
AbleAntecedentClause(AbleRd theLhs, int theOp, AbleRd theRhs)
          Create a new clause with the specified parts.
AbleAntecedentClause(AbleRd theLhs, int theOp, AbleRd theRhs, double theClauseWeight)
          Create a new antecedent clause with the specified parts.
 
Method Summary
 java.lang.String arlString()
          Return a formal ARL string that describes this clause.
 AbleAntecedentClause createMatchClause(java.util.Hashtable replacementVars)
          Create a duplicate of this clause using replacement vars
protected  boolean equals(AbleAntecedentClause theAbleClause)
          Determine whether this clause is equal to some other clause.
 java.lang.Boolean getBooleanTruth()
          Retrieve the clause's truth value.
 double getClauseWeight()
          Retrieve the clause's weight.
 java.lang.String getTemplateString(java.util.Vector theTemplateVars)
          Retrieve a text format string for use by rule templates.
 void setBooleanTruth(java.lang.Boolean theTruth)
          Set the clause's truth value.
 void setClauseWeight(double theClauseWeight)
          Set the clause's weight to the specified value.
 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 that describes this clause.
 
Methods inherited from class com.ibm.able.rules.AbleClause
addRuleRef, Copyright, equals, getLhs, getLhsReferent, getOp, getOpAsString, getReferent, getReferents, getRhs, getRhsReferent, getRule, getRuleRefs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

ClauseWeightDefault

public static final double ClauseWeightDefault
A default weight.

myClauseWeight

protected double myClauseWeight
myClauseWeight represents the weight that this clause is to assume when the clause is evaluated. This field is initialized to ClauseWeightDefault, which means "unweighted".

myBooleanTruth

protected java.lang.Boolean myBooleanTruth
myBooleanTruth contains the current truth value of this clause, but only if the clause has been evaluated. The current value is always either true, false, or null. null means that the truth value is unknown or cannot be determined, perhaps because one of the operands has not been set. This field is initialized to null.
Constructor Detail

AbleAntecedentClause

public AbleAntecedentClause(AbleRd theLhs,
                            int theOp,
                            AbleRd theRhs,
                            double theClauseWeight)
Create a new antecedent clause with the specified parts.
Parameters:
theLhs - The left-hand side of the clause.

theOp - A relational operator with which to evaluate the two sides, or operands, of this clause. The value must be an AbleData.<Operator> constant.

theRhs - The right-hand side of the clause.

theClauseWeight - The weight of the clause (used by Fuzzy engine only).


AbleAntecedentClause

public AbleAntecedentClause(AbleRd theLhs,
                            int theOp,
                            AbleRd theRhs)
Create a new clause with the specified parts. The clause's weight is set to ClauseWeightDefault (unweighted).
Parameters:
theLhs - The left-hand side of the clause.

theOp - A relational operator with which to evaluate the two sides, or operands, of this clause. The value must be an AbleData.<Operator> constant.

theRhs - The right-hand side of the clause.


AbleAntecedentClause

public AbleAntecedentClause(AbleExpression theExpression)
                     throws AbleDataException
Create a new clause from the specified expression. If, for some reason the expression cannot be represented as an antecedent clause, an exception will be thrown.
Parameters:
theExpression - A simple boolean expression with an optional weight
Method Detail

createMatchClause

public AbleAntecedentClause createMatchClause(java.util.Hashtable replacementVars)
Create a duplicate of this clause using replacement vars

arlString

public java.lang.String arlString()
Return a formal ARL string that describes this clause.

For antecedent clauses, add the weight of the clause, but only if the weight is something other than the default weight.

Overrides:
arlString in class AbleClause
Returns:
A String that describes this clause in formal rule language.

xmlString

public java.lang.String xmlString()
Return a formal XML string that describes this clause.

For antecedent clauses, add the weight of the clause, but only if the weight is something other than the default weight.

Overrides:
xmlString in class AbleClause
Returns:
A String that describes this clause in XML.

getTemplateString

public java.lang.String getTemplateString(java.util.Vector theTemplateVars)
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.
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

setClauseWeight

public final void setClauseWeight(double theClauseWeight)
Set the clause's weight to the specified value. The new weight replaces the current weight.
Parameters:
theClauseWeight - The new weight of the clause.


getClauseWeight

public final double getClauseWeight()
Retrieve the clause's weight.
Returns:
The clause's weight.

setBooleanTruth

public final void setBooleanTruth(java.lang.Boolean theTruth)
Set the clause's truth value.
Parameters:
theTruth - true if the clause evaluates to true; false if the clause evaluates to false; null if the truth value is unknown.

getBooleanTruth

public final java.lang.Boolean getBooleanTruth()
Retrieve the clause's truth value.
Returns:
true if the clause evaluates to true; false if the clause evaluates to false; null if the truth value is unknown.

equals

protected boolean equals(AbleAntecedentClause theAbleClause)
Determine whether this clause is equal to some other clause.

For the clauses to be considered equal:

Parameters:
theAbleClause - The clause that is to be compared to this clause.

Returns:
true if the clauses are equal; false otherwise.

toString

public java.lang.String toString()
Retrieve a string describing (the contents of) the object.
Overrides:
toString in class AbleClause
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 AbleClause
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