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

com.ibm.able.data
Class AbleArrayVariable

java.lang.Object
  |
  +--com.ibm.able.data.AbleLhs
        |
        +--com.ibm.able.data.AbleVariable
              |
              +--com.ibm.able.data.AbleGenericVariable
                    |
                    +--com.ibm.able.data.AbleTypedVariable
                          |
                          +--com.ibm.able.data.AbleArrayVariable
All Implemented Interfaces:
AbleRd, AbleWr, java.io.Serializable

public class AbleArrayVariable
extends AbleTypedVariable
implements java.io.Serializable

This class wraps a value of the type Object[] in an AbleVariable object. An object of type AbleArrayVariable contains a single, mutable field whose type is Object[]. Instances of AbleArrayVariable are used by the Able rules classes in clauses and expressions. In addition, this class provides methods for replacing the entire contents of the variable or single elements based on index value.

See Also:
Serialized Form

Field Summary
protected  java.lang.String myArrayType
          The data type of the elements in the array.
protected  java.lang.Class myArrayTypeClass
          The Class of the array type (underlying elements) of the array.
protected  java.lang.Class[] myElementClasses
          The data types of the elements of this array.
protected  int myLength
          The number of elements in the array.
protected  java.lang.Object[] myValue
          The current value of the variable.
 
Fields inherited from class com.ibm.able.data.AbleTypedVariable
myDataTypeClass, myDataTypeClassName, myDataTypeName, myInitialParms
 
Fields inherited from class com.ibm.able.data.AbleVariable
myBoundFlag, myChgSupport, myComment, myContext, myDataType, myGlobalFlag, myId, myName, myPrompt, myReferences, myStaticFlag, myTemplateFlag, myValueInitial
 
Constructor Summary
AbleArrayVariable(java.lang.String theName, boolean theStaticFlag, boolean theGlobalFlag, java.lang.String theArrayType, int theLength)
          Create a new array variable.
AbleArrayVariable(java.lang.String theName, java.lang.String theArrayType, int theLength)
          Create a new array variable.
 
Method Summary
 java.lang.String arlDclString()
          Return a formal ARL "declaration" string that describes this data object.
 void asgnEq(AbleRd theRhs)
          Assignment: assign the current value of theRhs to 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 cmpNeq(AbleRd theRhs)
          Comparison, not equal to: compare the current value of this data object to the current value of theRhs.
 boolean getBooleanValue()
          Retrieve the value of this data object as a boolean value.
 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.
 java.lang.Class getElementClass()
          Retrieve the class of this variable'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 Array of Objects of the element type.
 int getLength()
           
 java.lang.Class getLiteralClass()
          Retrieve the class of this variable's related AbleLiteral data type.
 double getNumericValue()
          Retrieve the value of this data object as a numeric value.
protected  java.lang.Object getRawValue()
          Retrieve the variable's current value.
 java.lang.String getStringValue()
          Retrieve the value of this data object as a string value.
 AbleLiteral getValue()
          Retrieve the value of this data object as a literal.
 AbleLiteral getValueAt(int theIndex)
          Retrieve the value of the specified element of the array as a literal.
 java.lang.String getValueString()
          Retrieve the variable's current value as a string.
 void init()
          Init the variable to its initial state.
 void replaceValues(java.lang.Object theNewValue)
          Replace both the current value and the initial value with the specified new value.
 void reset()
          Reset the variable to its intial state.
 void setBooleanValue(boolean theNewValue)
          Set the value of this data object from a boolean value.
 void setFuzzyValue(AbleFuzzySet theNewValue)
          Set the value of this data object from a fuzzy value.
 void setGenericValue(java.lang.Object theNewValue)
          Set the value of this data object from an object.
 void setLength(int theLength)
          Set the number of elements (length) of the array variable Note: initial values and setValue must match this length The current contents of the array variable will be destroyed.
 void setNumericValue(double theNewValue)
          Set the value of this data object from a numeric value.
protected  void setRawValue(java.lang.Object theNewValue)
          Set the variable's current value.
 void setStringValue(java.lang.String theNewValue)
          Set the value of this data object from a string value.
 void setValue(AbleLiteral theNewValue)
          Set the value of this data object from a literal object.
 void setValueAt(int theIndex, AbleRd theNewValue)
          Set the value of the specified element of the array as a literal.
 void setValueString(java.lang.String theNewValue)
          Set the variable's current value from a string.
 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 xmlDclString()
          Return a formal XML "declaration" string that describes this data object.
 
Methods inherited from class com.ibm.able.data.AbleTypedVariable
getDataTypeName
 
Methods inherited from class com.ibm.able.data.AbleGenericVariable
cmpGt, cmpGtEq, cmpIs, cmpLt, cmpLtEq, compDivide, compMinus, compMultiply, compPlus, compUnaryMinus
 
Methods inherited from class com.ibm.able.data.AbleVariable
arlCRdString, arlInitializerString, getArlComment, getChgSupport, getComment, getContext, getDataType, getDataTypeAsString, getId, getName, getPrompt, getPromptString, getReferences, getReferent, getReferents, getTemplateString, isBound, isConstant, isGlobal, isLocal, isStatic, isTemplate, notStatic, setChgSupport, setComment, setContext, setId, setInitialValue, setPrompt, setReferences, setStatic, setTemplate, xmlCRdString, xmlCWrString, xmlInitializerString
 
Methods inherited from class com.ibm.able.data.AbleLhs
asgnIs, asgnIs, bitwiseAND, bitwiseNOT, bitwiseOR, bitwiseShiftLeft, bitwiseShiftRight, bitwiseShiftRightZeroFill, bitwiseXOR, compModulo, Copyright, logicalAND, logicalNOT, logicalOR
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myValue

protected java.lang.Object[] myValue
The current value of the variable.

myElementClasses

protected java.lang.Class[] myElementClasses
The data types of the elements of this array.

Note: usually an AbleVariable and AbleLiteral pair


myArrayType

protected java.lang.String myArrayType
The data type of the elements in the array.

Note: The actual Class types are defined in myElementClasses


myArrayTypeClass

protected java.lang.Class myArrayTypeClass
The Class of the array type (underlying elements) of the array.

Note: For example, a Double[] would have the array type class of double.class


myLength

protected int myLength
The number of elements in the array.
Constructor Detail

AbleArrayVariable

public AbleArrayVariable(java.lang.String theName,
                         java.lang.String theArrayType,
                         int theLength)
Create a new array variable. The initial value is null.
Parameters:
theName - The unique name of the variable.
theArrayType - The data type of the elements of this array
theLength - The number of elements in the array


AbleArrayVariable

public AbleArrayVariable(java.lang.String theName,
                         boolean theStaticFlag,
                         boolean theGlobalFlag,
                         java.lang.String theArrayType,
                         int theLength)
Create a new array variable. The initial value is null.
Parameters:
theName - The unique name of the variable.

theStaticFlag - Use true if this variable is to be marked as static, which means that it will ignore future reset requests; use false if the variable can be reset to its initial value when requested.

theGlobalFlag - Use true if this variable is to be considered global; use false if the variable is to be considered local.

theArrayType - The data type of the elements of this array

theLength - The number of elements in the array

Method Detail

getBooleanValue

public boolean getBooleanValue()
                        throws AbleDataException
Retrieve the value of this data object as a boolean value.
Overrides:
getBooleanValue in class AbleGenericVariable
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 AbleGenericVariable
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 Array of Objects of the element type. AbleVariables and Literals will be dereferenced and return their underlying values as elements of the Array.
Overrides:
getGenericValue in class AbleGenericVariable
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 AbleGenericVariable
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 AbleGenericVariable
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.
Overrides:
getValue in class AbleGenericVariable
Returns:
An AbleGenericLiteral object.
Throws:
AbleDataException - If the value of this object cannot be represented as a literal.

asgnEq

public void asgnEq(AbleRd theRhs)
            throws AbleDataException
Assignment: assign the current value of theRhs to this data object.
Overrides:
asgnEq in class AbleGenericVariable
Parameters:
theRhs - The right-hand, or source, side of the assignment.

Throws:
AbleDataException - If the right-hand side cannot be converted (if necessary) and assigned to this data object.

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

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

setBooleanValue

public void setBooleanValue(boolean theNewValue)
                     throws AbleDataException
Set the value of this data object from a boolean value.
Overrides:
setBooleanValue in class AbleGenericVariable
Parameters:
theNewValue - A boolean value.

Throws:
AbleDataException - If the value of this object cannot be represented as a boolean value.

setFuzzyValue

public void setFuzzyValue(AbleFuzzySet theNewValue)
                   throws AbleDataException
Set the value of this data object from a fuzzy value. This method always throws an exception.
Overrides:
setFuzzyValue in class AbleGenericVariable
Parameters:
theNewValue - A fuzzy set.

Throws:
AbleDataException - If the value of this object cannot be represented as a fuzzy value.

setGenericValue

public void setGenericValue(java.lang.Object theNewValue)
                     throws AbleDataException
Set the value of this data object from an object.
Overrides:
setGenericValue in class AbleGenericVariable
Parameters:
theNewValue - Any type of Object.

Throws:
AbleDataException - If the value of this object cannot be derived from the specified Object.

setNumericValue

public void setNumericValue(double theNewValue)
                     throws AbleDataException
Set the value of this data object from a numeric value.
Overrides:
setNumericValue in class AbleGenericVariable
Parameters:
theNewValue - Any number.

Throws:
AbleDataException - If the value of this object cannot be represented as a numeric value.

setStringValue

public void setStringValue(java.lang.String theNewValue)
                    throws AbleDataException
Set the value of this data object from a string value.
Overrides:
setStringValue in class AbleTypedVariable
Parameters:
theNewValue - A string.

Throws:
AbleDataException - If the value of this object cannot be represented as a string value.

setValue

public void setValue(AbleLiteral theNewValue)
              throws AbleDataException
Set the value of this data object from a literal object.
Overrides:
setValue in class AbleGenericVariable
Parameters:
theNewValue - An Able literal of any type. An attempt is made to convert the literal to an appropriate type before assigning it to this "writable" object.

Throws:
AbleDataException - If the value of this object cannot be determined from the literal object.

arlDclString

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

xmlDclString

public java.lang.String xmlDclString()
Return a formal XML "declaration" string that describes this data object.
Overrides:
xmlDclString in class AbleTypedVariable
Returns:
A String describing the data object in XML.

setValueString

public void setValueString(java.lang.String theNewValue)
                    throws AbleDataException
Set the variable's current value from a string. Note: This method is provided for the use of a rule language parser.
Overrides:
setValueString in class AbleGenericVariable

getValueString

public java.lang.String getValueString()
Retrieve the variable's current value as a string. Note: This method is provided for the use of a rule language parser.
Overrides:
getValueString in class AbleGenericVariable

reset

public void reset()
           throws AbleDataException
Reset the variable to its intial state.
Overrides:
reset in class AbleTypedVariable

init

public void init()
          throws AbleDataException
Init the variable to its initial state.
Overrides:
init in class AbleTypedVariable

setLength

public void setLength(int theLength)
Set the number of elements (length) of the array variable Note: initial values and setValue must match this length The current contents of the array variable will be destroyed.

getLength

public int getLength()

getDataTypeClass

public java.lang.Class getDataTypeClass()
Description copied from class: AbleLhs
Retrieve the actual class of this object's underlying data type.
Overrides:
getDataTypeClass in class AbleTypedVariable
Following copied from class: com.ibm.able.data.AbleLhs
Returns:
The class of the underlying data type.

getDataTypeClassName

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

getElementClass

public java.lang.Class getElementClass()
Retrieve the class of this variable's underlying data type
Returns:
The class of the element data type.

getLiteralClass

public java.lang.Class getLiteralClass()
Retrieve the class of this variable's related AbleLiteral data type.
Overrides:
getLiteralClass in class AbleGenericVariable
Returns:
The class of the literal data type.

getValueAt

public AbleLiteral getValueAt(int theIndex)
                       throws AbleDataException
Retrieve the value of the specified element of the array as a literal.
Returns:
An AbleGenericLiteral object.
Throws:
AbleDataException - If the value of this object cannot be represented as a literal or if the index is invalid.

setValueAt

public void setValueAt(int theIndex,
                       AbleRd theNewValue)
                throws AbleDataException
Set the value of the specified element of the array as a literal.
Parameters:
theIndex - The integer value of the array element to set
theNewValue - An Object value used to set the specified array element.
Throws:
AbleDataException - If the value of this object cannot be represented as a literal or if the index is invalid.

setRawValue

protected void setRawValue(java.lang.Object theNewValue)
                    throws AbleDataException
Set the variable's current value.

Note that this method fires a PropertyChange with both old and new values, but only if a PropertyChangeSupport object has been set in the variable.

Note that this method updates all objects that refer to this variable, but only if a set of references has been set in the variable.

Overrides:
setRawValue in class AbleTypedVariable

getRawValue

protected java.lang.Object getRawValue()
Retrieve the variable's current value.

replaceValues

public void replaceValues(java.lang.Object theNewValue)
Replace both the current value and the initial value with the specified new value.

Even though this method is public, it is primarily for the use of AbleRuleSet objects so that the special builtin variables can be updated easily when the ruleset's parent changes. It is dangerous for others to use this method.

Overrides:
replaceValues in class AbleGenericVariable
Parameters:
theNewValue - Any type of Object.


toString

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