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

com.ibm.able.data
Class AbleExpression

java.lang.Object
  |
  +--com.ibm.able.data.AbleLiteral
        |
        +--com.ibm.able.data.AbleExpression
All Implemented Interfaces:
AbleRd, java.io.Serializable

public class AbleExpression
extends AbleLiteral

An AbleExpression contains a unary or binary operator along with one or two AbleRd objects (which themselves could be AbleExpressions).

See Also:
Serialized Form

Field Summary
static double DefaultWeight
          A default weight.
protected  AbleRd myLhs
          myLhs represents the left-hand side of this clause.
protected  int myOp
          myOp is the unary or binary operator to be used to evaluate the left-hand side of this clause against the right-hand side of this clause.
protected  AbleRd myRhs
          myRhs represents the right-hand side of this clause.
protected  AbleRd myValue
          myValue represents the value of this expression when the left-hand side and the right-hand side values are computed and the operator is applied.
protected  double myWeight
          myWeight represents the weight that this expression should be given when it is converted to an antecedent clause This field is initialized to DefaultWeight which means "unweighted".
 
Constructor Summary
AbleExpression(AbleDataContext theRuleSet, java.lang.String theExprString)
          Create a new expression from the String.
AbleExpression(AbleRd theLhs, int theOp, AbleRd theRhs)
          Create a new clause with the specified parts.
 
Method Summary
 java.lang.String arlCRdString()
          Return a formal ARL "clause read" string that describes this data object.
 java.util.Vector convertToConjunctiveNormalForm()
          Convert this Expression into conjunctive normal form a list of ANDed AbleExpressions
 java.util.Vector convertToDisjunctiveNormalForm()
          Convert this Expression into disjunctive normal form a list of ORed AbleExpressions
 AbleExpression createMatchExpression(java.util.Hashtable replacementVars)
          Create a duplicate of this expression using replacement vars
 boolean equals(AbleExpression theExpr)
          Determine whether this expression is equal to some other expression.
 boolean equals(java.lang.Object theExpr)
           
 boolean getBooleanValue()
          Retrieve the value of this data object as a boolean value.
 int getDataType()
          Retrieve the data type of this data object.
 java.lang.Class getDataTypeClass()
          Return expression value data type
 java.lang.String getDataTypeClassName()
          Retrieve the name of the class of this object's underlying data type.
 AbleFuzzySet getFuzzyValue()
          Retrieve the value of this data object as a fuzzy value.
 java.lang.Object getGenericValue()
          Retrieve the value of this data object as an Object.
 AbleRd getLhs()
          Retrieve the expression's left-hand side.
 double getNumericValue()
          Retrieve the value of this data object as a numeric value.
 int getOp()
          Retrieve the expression's operator.
 java.lang.String getOpAsString()
          Retrieve the expression's operator in human-readable string form.
 java.util.BitSet getReferents()
          Retrieve the Ids of the variables to which this data object refers, if any.
 AbleRd getRhs()
          Retrieve the expression's right-hand side.
 java.lang.String getStringValue()
          Retrieve the value of this data object as a string value.
 java.lang.String getTemplateString(java.util.Vector theTemplateVars)
          Retrieve a text format string for use by rule templates.
 AbleLiteral getValue()
          Compute the value of this expression clause and return the value as an AbleLiteral
 java.util.HashSet getVariableReferences()
          Retrieve the set of variables (if any) referenced by this expression (and subexpressions)
 double getWeight()
          Retrieve the weight used when the expression is converted to an antecedent clause.
 boolean isComplexExpression()
          Returns true if either LHS or RHS args are AbleExpressions
 boolean isCompoundExpression()
          Returns true if both LHS and RHS args are AbleExpressions
 boolean isConstant()
          Returns true if this AbleRd object is a constant value false, if it does not.
 boolean isSimpleExpression()
          Returns true if neither the LHS nor RHS args are AbleExpressions
 void setWeight(double theWeight)
          Set the weight to the specified value.
 java.lang.String traceString(int theTraceStringFlavor)
          Retrieve a string describing (the contents of) the object.
 java.lang.String xmlCRdString()
          Return a formal XML "clause read" string that describes this data object.
 
Methods inherited from class com.ibm.able.data.AbleLiteral
bitwiseAND, bitwiseNOT, bitwiseOR, bitwiseShiftLeft, bitwiseShiftRight, bitwiseShiftRightZeroFill, bitwiseXOR, cmpEq, cmpGt, cmpGtEq, cmpIs, cmpLt, cmpLtEq, cmpNeq, compDivide, compMinus, compModulo, compMultiply, compPlus, compUnaryMinus, Copyright, getDataTypeAsString, getReferent, logicalAND, logicalNOT, logicalOR, toString
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myLhs

protected AbleRd myLhs
myLhs represents the left-hand side of this clause. This field is initialized by the constructor.

myOp

protected int myOp
myOp is the unary or binary operator to be used to evaluate the left-hand side of this clause against the right-hand side of this clause. The value must be an AbleData.<Operator> constant. This field is initialized by the constructor.

myRhs

protected AbleRd myRhs
myRhs represents the right-hand side of this clause. This field is initialized by the constructor.

myValue

protected transient AbleRd myValue
myValue represents the value of this expression when the left-hand side and the right-hand side values are computed and the operator is applied.

This field is initialized by the constructor.


DefaultWeight

public static final double DefaultWeight
A default weight.

myWeight

protected double myWeight
myWeight represents the weight that this expression should be given when it is converted to an antecedent clause This field is initialized to DefaultWeight which means "unweighted".
Constructor Detail

AbleExpression

public AbleExpression(AbleRd theLhs,
                      int theOp,
                      AbleRd theRhs)
Create a new clause with the specified parts.

If either the left-hand side or the right-hand side is a variable, and that variable is keeping track of clauses in which the variable is referenced, the variable's set of references is updated to point to this clause.

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.


AbleExpression

public AbleExpression(AbleDataContext theRuleSet,
                      java.lang.String theExprString)
               throws AbleException
Create a new expression from the String.
Parameters:
theRuleSet - The data context used to parse the String into an expression
theExprString - The expression String.

Method Detail

createMatchExpression

public AbleExpression createMatchExpression(java.util.Hashtable replacementVars)
Create a duplicate of this expression using replacement vars

getLhs

public final AbleRd getLhs()
Retrieve the expression's left-hand side.
Returns:
An AbleData left-hand side object.

getOp

public final int getOp()
Retrieve the expression's operator.
Returns:
An AbleData.<Operator> constant.

getOpAsString

public java.lang.String getOpAsString()
Retrieve the expression's operator in human-readable string form.
Returns:
A string of the form: "n:AbleData.<Operator>", where n is the actual constant and "<Operator>" is the name of the constant.

getRhs

public final AbleRd getRhs()
Retrieve the expression's right-hand side.
Returns:
An AbleData "readable" object.

getReferents

public java.util.BitSet getReferents()
Retrieve the Ids of the variables to which this data object refers, if any. Must be overriden by subclasses which can refer to variables.
Overrides:
getReferents in class AbleLiteral
Returns:
The Ids of the variables to which this data object refers, or AbleData.VarIdNull if the data object is a literal and therefore refers to no variable.

traceString

public java.lang.String traceString(int theTraceStringFlavor)
Description copied from class: AbleLiteral
Retrieve a string describing (the contents of) the object.
Overrides:
traceString in class AbleLiteral
See Also:
AbleLiteral.traceString(int)

xmlCRdString

public java.lang.String xmlCRdString()
Description copied from class: AbleLiteral
Return a formal XML "clause read" string that describes this data object.
Overrides:
xmlCRdString in class AbleLiteral
See Also:
AbleLiteral.xmlCRdString()

arlCRdString

public java.lang.String arlCRdString()
Description copied from class: AbleLiteral
Return a formal ARL "clause read" string that describes this data object.
Overrides:
arlCRdString in class AbleLiteral
See Also:
AbleLiteral.arlCRdString()

convertToConjunctiveNormalForm

public java.util.Vector convertToConjunctiveNormalForm()
Convert this Expression into conjunctive normal form a list of ANDed AbleExpressions
Returns:
A Vector of AbleExpression objects

convertToDisjunctiveNormalForm

public java.util.Vector convertToDisjunctiveNormalForm()
Convert this Expression into disjunctive normal form a list of ORed AbleExpressions
Returns:
A Vector of AbleExpression objects

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.
Overrides:
getTemplateString in class AbleLiteral
Parameters:
theTemplateVars - An ordered list of template variables referenced by this rule.
Returns:
A Text format string used to create a new rule instance.

getValue

public AbleLiteral getValue()
                     throws AbleDataException
Compute the value of this expression clause and return the value as an AbleLiteral
Overrides:
getValue in class AbleLiteral
See Also:
AbleLiteral.getValue()

getStringValue

public java.lang.String getStringValue()
                                throws AbleDataException
Description copied from class: AbleLiteral
Retrieve the value of this data object as a string value.
Overrides:
getStringValue in class AbleLiteral
See Also:
AbleLiteral.getStringValue()

getNumericValue

public double getNumericValue()
                       throws AbleDataException
Description copied from class: AbleLiteral
Retrieve the value of this data object as a numeric value.
Overrides:
getNumericValue in class AbleLiteral
See Also:
AbleLiteral.getNumericValue()

getGenericValue

public java.lang.Object getGenericValue()
                                 throws AbleDataException
Description copied from class: AbleLiteral
Retrieve the value of this data object as an Object.
Overrides:
getGenericValue in class AbleLiteral
See Also:
AbleLiteral.getGenericValue()

getFuzzyValue

public AbleFuzzySet getFuzzyValue()
                           throws AbleDataException
Description copied from class: AbleLiteral
Retrieve the value of this data object as a fuzzy value.
Overrides:
getFuzzyValue in class AbleLiteral
See Also:
AbleLiteral.getFuzzyValue()

getBooleanValue

public boolean getBooleanValue()
                        throws AbleDataException
Description copied from class: AbleLiteral
Retrieve the value of this data object as a boolean value.
Overrides:
getBooleanValue in class AbleLiteral
See Also:
AbleLiteral.getBooleanValue()

getDataTypeClass

public java.lang.Class getDataTypeClass()
Return expression value data type
Overrides:
getDataTypeClass in class AbleLiteral
Following copied from class: com.ibm.able.data.AbleLiteral
Returns:
The class of the underlying data type.

getDataTypeClassName

public java.lang.String getDataTypeClassName()
Description copied from class: AbleLiteral
Retrieve the name of the class of this object's underlying data type.
Overrides:
getDataTypeClassName in class AbleLiteral
Following copied from class: com.ibm.able.data.AbleLiteral
Returns:
A String that is the name of the class of the underlying data type.

setWeight

public final void setWeight(double theWeight)
Set the weight to the specified value. The new weight replaces the current weight.
Parameters:
theWeight - The new weight used if the expression is converted to an antecedent clause.


getWeight

public final double getWeight()
Retrieve the weight used when the expression is converted to an antecedent clause.
Returns:
The weight.

getVariableReferences

public java.util.HashSet getVariableReferences()
Retrieve the set of variables (if any) referenced by this expression (and subexpressions)

equals

public boolean equals(AbleExpression theExpr)
Determine whether this expression is equal to some other expression.

For the expressions to be considered equal:

Parameters:
theAbleExpression - The expression that is to be compared to this expression.

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

equals

public boolean equals(java.lang.Object theExpr)
Overrides:
equals in class java.lang.Object

isSimpleExpression

public boolean isSimpleExpression()
Returns true if neither the LHS nor RHS args are AbleExpressions

isComplexExpression

public boolean isComplexExpression()
Returns true if either LHS or RHS args are AbleExpressions

isCompoundExpression

public boolean isCompoundExpression()
Returns true if both LHS and RHS args are AbleExpressions

isConstant

public boolean isConstant()
Description copied from interface: AbleRd
Returns true if this AbleRd object is a constant value false, if it does not.
Overrides:
isConstant in class AbleLiteral

getDataType

public int getDataType()
Description copied from class: AbleLiteral
Retrieve the data type of this data object.
Overrides:
getDataType in class AbleLiteral
See Also:
AbleRd.getDataType()

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

(C) Copyright IBM Corporation 1999, 2003