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

com.ibm.able.data
Class AbleCallLiteral

java.lang.Object
  |
  +--com.ibm.able.data.AbleLiteral
        |
        +--com.ibm.able.data.AbleCallLiteral
All Implemented Interfaces:
AbleRd, java.io.Serializable
Direct Known Subclasses:
AbleTypedVariableMethodLiteral

public class AbleCallLiteral
extends AbleLiteral
implements java.io.Serializable

This class performs a method invocation to a specific method on an object in an Able ruleset. The constructor uses introspection to try to find a constructor method on the target class that matches the specified argument types. This literal behaves somewhat differently from other AbleLiterals, in that is not strictly a constant, it invokes the same method on the same typed variable, but the underlying Object being invoked may change during the course of a ruleset evaluation.

See Also:
Serialized Form

Field Summary
protected  java.util.Vector myArgs
          A list of arguments to the user-defined function named by myCallee.
protected  int myArity
          The number of arguments to the user-defined function named by myCallee.
protected  java.lang.String myCallee
          The name of the user-defined function (method) owned by myUdfMgr to call when the current value of this literal is requested.
protected  java.lang.Object myUdfMgr
          An object that implements the AbleUserDefinedFunctionManager interface.
protected  java.lang.Object myValue
          The current value of this literal.
 
Constructor Summary
AbleCallLiteral(AbleCallLiteral theCallLiteral, java.util.Vector theArgs)
          Create a copy of this call literal with replacement args
AbleCallLiteral(java.lang.Object theUdfMgr, java.lang.String theCallee, java.util.Vector theArgs)
          Create a new Able data call object with the specified information.
AbleCallLiteral(java.lang.String theCallee, java.util.Vector theArgs)
          Create a new Able data method object with the specified information.
 
Method Summary
 java.lang.String arlCRdString()
          Return a formal ARL "clause read" string that describes this data object.
 boolean cmpEq(AbleRd theRhs)
          Comparison, equal to: compare the current value of this data object to the current value of theRhs.
 boolean cmpGt(AbleRd theRhs)
          Comparison, greater than: compare the current value of this data object to the current value of theRhs.
 boolean cmpGtEq(AbleRd theRhs)
          Comparison, greater than or equal to: compare the current value of this data object to the current value of theRhs.
 boolean cmpLt(AbleRd theRhs)
          Comparison, less than: compare the current value of this data object to the current value of theRhs.
 boolean cmpLtEq(AbleRd theRhs)
          Comparison, less than or equal to: compare the current value of this data object to the current value of theRhs.
 boolean cmpNeq(AbleRd theRhs)
          Comparison, not equal to: compare the current value of this data object to the current value of theRhs.
 AbleLiteral compDivide(AbleRd theRhs)
          Compute, divide the current value of this data object by the current value of theRhs.
 AbleLiteral compMinus(AbleRd theRhs)
          Compute, subtract the current value of theRhs from the current value of this object.
 AbleLiteral compMultiply(AbleRd theRhs)
          Compute, multiply the current value of this data object to the current value of theRhs.
 AbleLiteral compPlus(AbleRd theRhs)
          Compute, add the current value of this data object to the current value of theRhs.
 AbleLiteral compUnaryMinus(AbleRd theRhs)
          Compute, the unary minus of the current value of this object.
protected  java.lang.Object[] cvtArgs(java.util.Vector theArgs)
           
 java.util.Vector getArgs()
           
 int getArity()
           
 boolean getBooleanValue()
          Retrieve the value of this data object as a boolean value.
 java.lang.String getCallee()
           
 java.lang.String getCalleeWithArgs()
           
 java.lang.String getCalleeWithArity()
           
 int getDataType()
          Retrieve the data type of this data object.
 java.lang.Class getDataTypeClass()
          Retrieve the actual class of this object's underlying 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.
 double getNumericValue()
          Retrieve the value of this data object as a numeric value.
 java.lang.Object getRawValue()
           
 java.util.BitSet getReferents()
          Retrieve the Ids of the variables to which this data object refers, if any.
 java.lang.Class getReturnType()
          Get the data type of the value returned from the associated method invocation.
 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()
          Retrieve the value of this data object as a literal.
 java.util.HashSet getVariableReferences()
          Retrieve the set of variables (if any) referenced by this expression (and subexpressions)
 boolean isConstant()
          Returns true if this AbleRd object is a constant value false, if it does not.
 boolean logicalAND(AbleRd theRhs)
          Logical AND the current value of this data object with the current value of theRhs.
 boolean logicalNOT(AbleRd theRhs)
          Logical NOT: complement the current value of this data object.
 boolean logicalOR(AbleRd theRhs)
          Logical OR the current value of this data object with the current value of theRhs.
protected  void performCall()
           
 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 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, cmpIs, compModulo, Copyright, getDataTypeAsString, getReferent, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myValue

protected transient java.lang.Object myValue
The current value of this literal. Note that the value is immutable in that it cannot be set explicitly by the user; however, the value can and does change whenever the current value is requested. This is because a request for the current value of this literal causes the encapsulated user-defined function to also be called, and the function may return a different value on each call.

myUdfMgr

protected java.lang.Object myUdfMgr
An object that implements the AbleUserDefinedFunctionManager interface.

myCallee

protected java.lang.String myCallee
The name of the user-defined function (method) owned by myUdfMgr to call when the current value of this literal is requested.

myArgs

protected java.util.Vector myArgs
A list of arguments to the user-defined function named by myCallee. It can be empty, but must never be null.

myArity

protected int myArity
The number of arguments to the user-defined function named by myCallee.
Constructor Detail

AbleCallLiteral

public AbleCallLiteral(java.lang.Object theUdfMgr,
                       java.lang.String theCallee,
                       java.util.Vector theArgs)
Create a new Able data call object with the specified information. The initial value of this literal is null, and it remains null until this literal is requested to give up a value. At that time, the user-defined function is called to produce a value. Each time a value is requested from this literal, the user-defined function is recalled; be aware that the current value may thus change from time to time.
Parameters:
theUdfMgr - A reference to an object that implements either the AbleUserDefinedFunctionManager interface.

theCallee - The name of the user-defined function to call.

theArgs - A list of AbleRd objects whose runtime values will be passed to the user-defined function as arguments. Each converted argument will be a Boolean, a Double, a String, or an Object, depending on the type of each AbleRd object in the argument list. The list can be empty, but it must never be null.


AbleCallLiteral

public AbleCallLiteral(AbleCallLiteral theCallLiteral,
                       java.util.Vector theArgs)
Create a copy of this call literal with replacement args

AbleCallLiteral

public AbleCallLiteral(java.lang.String theCallee,
                       java.util.Vector theArgs)
Create a new Able data method object with the specified information. The initial value of this literal is null, and it remains null until this literal is requested to give up a value. At that time, the method is called to produce a value. Each time a value is requested from this literal, the method is recalled; be aware that the current value may thus change from time to time. This constructor is used by AbleTypedVariableMethodLiteral.
Parameters:
theDataType - An AbleData.<DataType> constant.

theCallee - The name of the method to call.

theArgs - A list of AbleRd objects whose runtime values will be passed to the user-defined function as arguments. Each converted argument will be a Boolean, a Double, a String, or an Object, depending on the type of each AbleRd object in the argument list. The list can be empty, but it must never be null.

Method Detail

getBooleanValue

public boolean getBooleanValue()
                        throws AbleDataException
Retrieve the value of this data object as a boolean value.
Overrides:
getBooleanValue in class AbleLiteral
Returns:
A boolean, if the value of this object can be represented as a boolean value.
Throws:
AbleDataException - If the value of this object cannot be represented as a boolean value.

getFuzzyValue

public AbleFuzzySet getFuzzyValue()
                           throws AbleDataException
Retrieve the value of this data object as a fuzzy value.
Overrides:
getFuzzyValue in class AbleLiteral
Returns:
A fuzzy set, if the value of this object can be represented as a fuzzy value. This method always throws an exception.
Throws:
AbleDataException - If the value of this object cannot be represented as a fuzzy value.

getGenericValue

public java.lang.Object getGenericValue()
                                 throws AbleDataException
Retrieve the value of this data object as an Object.
Overrides:
getGenericValue in class AbleLiteral
Returns:
Any type of object.
Throws:
AbleDataException - If the value of this object cannot be represented as an Object.

getNumericValue

public double getNumericValue()
                       throws AbleDataException
Retrieve the value of this data object as a numeric value.
Overrides:
getNumericValue in class AbleLiteral
Returns:
A double, if the value of this object can be represented as a numeric value.
Throws:
AbleDataException - If the value of this object cannot be represented as a numeric value.

getStringValue

public java.lang.String getStringValue()
                                throws AbleDataException
Retrieve the value of this data object as a string value.
Overrides:
getStringValue in class AbleLiteral
Returns:
A String, if the value of this object can be represented as a string value.
Throws:
AbleDataException - If the value of this object cannot be represented as a string value.

getValue

public AbleLiteral getValue()
                     throws AbleDataException
Retrieve the value of this data object as a literal.

The user-defined function is called, which must return either a Boolean, Number derivative, String, or Object object, which will be turned into an AbleLiteral and returned.

It is OK for a user-defined function to return null. It will be turned into an AbleGenericLiteral whose value is null.

If the user-defined function returns some other object than those listed above, an exception is thrown.

Overrides:
getValue in class AbleLiteral
Returns:
An AbleLiteral object.
Throws:
AbleDataException - If the value of this object cannot be represented as an Able data literal.

getDataTypeClass

public java.lang.Class getDataTypeClass()
Description copied from class: AbleLiteral
Retrieve the actual class of this object's underlying 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.

arlCRdString

public java.lang.String arlCRdString()
Return a formal ARL "clause read" string that describes this data object.
Overrides:
arlCRdString in class AbleLiteral
Returns:
A String describing the data object in formal rule language.

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.

xmlCRdString

public java.lang.String xmlCRdString()
Return a formal XML "clause read" string that describes this data object.
Overrides:
xmlCRdString in class AbleLiteral
Returns:
A String describing the data object in XML.

cmpEq

public boolean cmpEq(AbleRd theRhs)
              throws AbleDataException
Comparison, equal to: compare the current value of this data object to the current value of theRhs.

"==" is used for numeric and boolean compares; equals() is used for Object compares; and Collator.equals() is used for String compares.

Overrides:
cmpEq in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
true, if this data object is equal to theRhs; false, otherwise.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

cmpGt

public boolean cmpGt(AbleRd theRhs)
              throws AbleDataException
Comparison, greater than: compare the current value of this data object to the current value of theRhs.

">" is used for numeric compares; Collator.compare() is used for String compares. Use of other data types on the left-hand side causes an exception.

Overrides:
cmpGt in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
true, if this data object is greater than theRhs; false, otherwise.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

cmpGtEq

public boolean cmpGtEq(AbleRd theRhs)
                throws AbleDataException
Comparison, greater than or equal to: compare the current value of this data object to the current value of theRhs.

">=" is used for numeric compares; Collator.compare() is used for String compares. Use of other data types on the left-hand side causes an exception.

Overrides:
cmpGtEq in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
true, if this data object is greater than or equal to theRhs; false, otherwise.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

cmpLt

public boolean cmpLt(AbleRd theRhs)
              throws AbleDataException
Comparison, less than: compare the current value of this data object to the current value of theRhs.

"<" is used for numeric compares; Collator.compare() is used for String compares. Use of other data types on the left-hand side causes an exception.

Overrides:
cmpLt in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
true, if this data object is less than theRhs; false, otherwise.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

cmpLtEq

public boolean cmpLtEq(AbleRd theRhs)
                throws AbleDataException
Comparison, less than or equal to: compare the current value of this data object to the current value of theRhs.

"<=" is used for numeric compares; Collator.compare() is used for String compares. Use of other data types on the left-hand side causes an exception.

Overrides:
cmpLtEq in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
true, if this data object is less than or equal to theRhs; false, otherwise.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

cmpNeq

public boolean cmpNeq(AbleRd theRhs)
               throws AbleDataException
Comparison, not equal to: compare the current value of this data object to the current value of theRhs.

"!=" is used for numeric and boolean compares; ! equals() is used for Object compares; and ! Collator.equals() is used for String compares.

Overrides:
cmpNeq in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
true, if this data object is not equal to theRhs; false, otherwise.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

compPlus

public AbleLiteral compPlus(AbleRd theRhs)
                     throws AbleDataException
Compute, add the current value of this data object to the current value of theRhs.

"+" is used for numeric addtion and String concatenation.

Overrides:
compPlus in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
The result of the addition or concatenation operation.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

compMinus

public AbleLiteral compMinus(AbleRd theRhs)
                      throws AbleDataException
Compute, subtract the current value of theRhs from the current value of this object.

"-" is used for numeric subtraction.

Overrides:
compMinus in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
The result of the subtraction operation.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

compMultiply

public AbleLiteral compMultiply(AbleRd theRhs)
                         throws AbleDataException
Compute, multiply the current value of this data object to the current value of theRhs.

"*" is used for numeric multiplication.

Overrides:
compMultiply in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
The result of the multiplication operation.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

compDivide

public AbleLiteral compDivide(AbleRd theRhs)
                       throws AbleDataException
Compute, divide the current value of this data object by the current value of theRhs.

"/" is used for numeric division.

Overrides:
compDivide in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
The result of the division operation.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

compUnaryMinus

public AbleLiteral compUnaryMinus(AbleRd theRhs)
                           throws AbleDataException
Compute, the unary minus of the current value of this object.

"-" is used for numeric negation.

Overrides:
compUnaryMinus in class AbleLiteral
Parameters:
theRhs - The right-hand side of the operation (ignored).

Returns:
The result of the negation operation.
Throws:
AbleDataException - If the value of this data object cannot be negated.

logicalAND

public boolean logicalAND(AbleRd theRhs)
                   throws AbleDataException
Logical AND the current value of this data object with the current value of theRhs.

"&&" is used for boolean AND.

Overrides:
logicalAND in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
The result of the logical AND operation.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

logicalOR

public boolean logicalOR(AbleRd theRhs)
                  throws AbleDataException
Logical OR the current value of this data object with the current value of theRhs.

"||" is used for boolean OR.

Overrides:
logicalOR in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
The result of the logical OR operation.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

logicalNOT

public boolean logicalNOT(AbleRd theRhs)
                   throws AbleDataException
Logical NOT: complement the current value of this data object.

"!" is used for boolean NOT.

Overrides:
logicalNOT in class AbleLiteral
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
The result of the boolean NOT operation.
Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and compared to this data object.

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

getRawValue

public java.lang.Object getRawValue()

getCallee

public java.lang.String getCallee()

getCalleeWithArity

public java.lang.String getCalleeWithArity()

getCalleeWithArgs

public java.lang.String getCalleeWithArgs()
                                   throws AbleDataException

getArgs

public java.util.Vector getArgs()

getArity

public int getArity()

performCall

protected void performCall()
                    throws AbleDataException

cvtArgs

protected java.lang.Object[] cvtArgs(java.util.Vector theArgs)
                              throws AbleDataException

getReturnType

public java.lang.Class getReturnType()
                              throws java.rmi.RemoteException
Get the data type of the value returned from the associated method invocation.
Returns:
The class representing the return type of the method

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)
Retrieve a string describing (the contents of) the object.
Overrides:
traceString in class AbleLiteral
Parameters:
theFlavor - An Able.TraceStringFlavor value.

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

trcString

protected java.lang.String trcString(int theTraceStringFlavor)

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

getVariableReferences

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

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

(C) Copyright IBM Corporation 1999, 2003