ABLE 2.3.0 07/13/2005 14:21:00

com.ibm.able.data
Class AbleStringVariable

java.lang.Object
  extended bycom.ibm.able.data.AbleLhs
      extended bycom.ibm.able.data.AbleVariable
          extended bycom.ibm.able.data.AbleTypedVariable
              extended bycom.ibm.able.data.AbleStringVariable
All Implemented Interfaces:
AbleClearable, AbleRd, AbleWr, java.io.Serializable

public class AbleStringVariable
extends AbleTypedVariable
implements java.io.Serializable

This class wraps a value of java.lang.String type in an object. An object of type AbleStringVariable contains a single, mutable field whose type is String. Instances of AbleStringVariable are used by the Able rules classes in clauses and expressions. In addition, this class provides methods for converting a String to other datatypes, setting a String value using other datatypes, as well as other logical comparison methods useful when dealing with a String.

See Also:
Serialized Form

Field Summary
protected  java.lang.String 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
AbleStringVariable(java.lang.String theName, boolean theStaticFlag, boolean theGlobalFlag)
          Create a new string variable with null initial value.
AbleStringVariable(java.lang.String theName, boolean theStaticFlag, boolean theGlobalFlag, java.lang.String theInitialValue)
          Create a new string variable with the specified initial value.
AbleStringVariable(java.lang.String theName, java.lang.String theInitialValue)
          Create a new string variable with the specified initial value.
 
Method Summary
 java.lang.String arlDclString()
          Return a formal ARL "declaration" string that describes this data object.
 java.lang.String armlDclString()
          Return a formal XML "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 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 compPlus(AbleRd theRhs)
          Compute, concatenate 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.
 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.
 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.
 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.
 java.lang.String getValueString()
          Retrieve the variable's current value as a string.
 void init()
          Init the variable to its initial state.
 void reset()
          Reset the variable to its initial 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 setNumericValue(double theNewValue)
          Set the value of this data object from a numeric 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 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
clear, cmpIs, compDivide, compMinus, compMultiply, compUnaryMinus, getDataTypeName, replaceValues
 
Methods inherited from class com.ibm.able.data.AbleVariable
arlCRdString, arlInitializerString, armlCRdString, armlInitializerString, 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, 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.String myValue
The current value of the variable.

Constructor Detail

AbleStringVariable

public AbleStringVariable(java.lang.String theName,
                          java.lang.String theInitialValue)
Create a new string variable with the specified initial value.

Parameters:
theName - The unique name of the variable.

theInitialValue - The value to which this variable is initially set.


AbleStringVariable

public AbleStringVariable(java.lang.String theName,
                          boolean theStaticFlag,
                          boolean theGlobalFlag)
Create a new string variable with null initial value.

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.


AbleStringVariable

public AbleStringVariable(java.lang.String theName,
                          boolean theStaticFlag,
                          boolean theGlobalFlag,
                          java.lang.String theInitialValue)
Create a new string variable with the specified initial value.

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.

theInitialValue - The value to which this variable is initially set.

Method Detail

getBooleanValue

public boolean getBooleanValue()
                        throws AbleDataException
Retrieve the value of this data object as a boolean value.

Specified by:
getBooleanValue in interface AbleRd
Overrides:
getBooleanValue in class AbleTypedVariable
Returns:
A boolean, if the value of this object can be represented as a boolean value. If the current value is "true" (case insensitive), true is returned; if the current value is "false" (case insensitive), false is returned; any other current value throws an exception.
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.

Specified by:
getFuzzyValue in interface AbleRd
Overrides:
getFuzzyValue in class AbleTypedVariable
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.

Specified by:
getGenericValue in interface AbleRd
Overrides:
getGenericValue in class AbleTypedVariable
Returns:
A String 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.

Specified by:
getNumericValue in interface AbleRd
Overrides:
getNumericValue in class AbleTypedVariable
Returns:
A double, if the value of this object can be represented as a numeric value. If the current value can be parsed as a double, a double is returned; otherwise an exception is thrown.
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.

Specified by:
getStringValue in interface AbleRd
Overrides:
getStringValue in class AbleTypedVariable
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.

Specified by:
getValue in interface AbleRd
Overrides:
getValue in class AbleTypedVariable
Returns:
An AbleStringLiteral 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.

Specified by:
asgnEq in interface AbleWr
Overrides:
asgnEq in class AbleTypedVariable
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 equals() is used for String compares.

Specified by:
cmpEq in interface AbleRd
Overrides:
cmpEq in class AbleTypedVariable
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.

Specified by:
cmpGt in interface AbleRd
Overrides:
cmpGt in class AbleTypedVariable
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.

Specified by:
cmpGtEq in interface AbleRd
Overrides:
cmpGtEq in class AbleTypedVariable
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.

Specified by:
cmpLt in interface AbleRd
Overrides:
cmpLt in class AbleTypedVariable
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.

Specified by:
cmpLtEq in interface AbleRd
Overrides:
cmpLtEq in class AbleTypedVariable
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 ! equals() is used for String compares.

Specified by:
cmpNeq in interface AbleRd
Overrides:
cmpNeq in class AbleTypedVariable
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, concatenate the current value of this data object to the current value of theRhs.

"+" is used for String concatenation.

Specified by:
compPlus in interface AbleRd
Overrides:
compPlus in class AbleTypedVariable
Parameters:
theRhs - The right-hand side of the comparison.

Returns:
The result of the concatenation operation.
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.

Specified by:
setBooleanValue in interface AbleWr
Overrides:
setBooleanValue in class AbleTypedVariable
Parameters:
theNewValue - A boolean value. If the new value is true the variable is set to "True"; if the new value is false the variable is set to "False".

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.

Specified by:
setFuzzyValue in interface AbleWr
Overrides:
setFuzzyValue in class AbleTypedVariable
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.

Specified by:
setGenericValue in interface AbleWr
Overrides:
setGenericValue in class AbleTypedVariable
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.

Specified by:
setNumericValue in interface AbleWr
Overrides:
setNumericValue in class AbleTypedVariable
Parameters:
theNewValue - Any number. The number is converted to a string and the variable is set to that string.

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.

Specified by:
setStringValue in interface AbleWr
Overrides:
setStringValue in class AbleTypedVariable
Parameters:
theNewValue - A string. The variable is set to the value of the string, but only if the string can be parsed to a double; otherwise an exception is thrown.

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.

Specified by:
setValue in interface AbleWr
Overrides:
setValue in class AbleTypedVariable
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.

Specified by:
arlDclString in interface AbleWr
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.

Specified by:
xmlDclString in interface AbleWr
Overrides:
xmlDclString in class AbleTypedVariable
Returns:
A String describing the data object in XML.

armlDclString

public java.lang.String armlDclString()
Return a formal XML "declaration" string that describes this data object.

Overrides:
armlDclString 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 AbleTypedVariable
Throws:
AbleDataException

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 AbleTypedVariable

reset

public void reset()
           throws AbleDataException
Reset the variable to its initial state.

Overrides:
reset in class AbleTypedVariable
Throws:
AbleDataException

init

public void init()
          throws AbleDataException
Init the variable to its initial state.

Overrides:
init in class AbleTypedVariable
Throws:
AbleDataException

getDataTypeClass

public java.lang.Class getDataTypeClass()
Description copied from class: AbleLhs
Retrieve the actual class of this object's underlying data type.

Specified by:
getDataTypeClass in interface AbleRd
Overrides:
getDataTypeClass in class AbleTypedVariable

getDataTypeClassName

public java.lang.String getDataTypeClassName()
Description copied from class: AbleLhs
Retrieve the name of the class of this object's underlying data type.

Specified by:
getDataTypeClassName in interface AbleRd
Overrides:
getDataTypeClassName in class AbleTypedVariable

getLiteralClass

public java.lang.Class getLiteralClass()
Retrieve the class of this variable's related AbleLiteral data type.

Overrides:
getLiteralClass in class AbleTypedVariable
Returns:
The class of the literal data type.

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.

Specified by:
traceString in interface AbleRd
Overrides:
traceString in class AbleTypedVariable
Parameters:
theTraceStringFlavor - An Able.TraceStringFlavor value.

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

ABLE 2.3.0 07/13/2005 14:21:00

(C) Copyright IBM Corporation 1999, 2005