ABLE, Version 1.1b

com.ibm.able.data
Class AbleContinuousVariable

java.lang.Object
  |
  +--com.ibm.able.data.AbleLhs
        |
        +--com.ibm.able.data.AbleVariable
              |
              +--com.ibm.able.data.AbleContinuousVariable
Direct Known Subclasses:
AbleContinuousField

public class AbleContinuousVariable
extends AbleVariable
implements java.io.Serializable

This class defines the Able data continuous variable.

Version:
$Revision: 1.8 $, $Date: 2000/09/26 14:27:10 $
See Also:
Serialized Form

Field Summary
protected  double myDiscourseHi
           
protected  double myDiscourseLo
           
protected  double myValue
           
protected  double myValueInitial
           
 
Fields inherited from class com.ibm.able.data.AbleVariable
myChgSupport, myContext, myDataType, myId, myName, myReferences
 
Constructor Summary
AbleContinuousVariable(java.lang.Object theContext, java.beans.PropertyChangeSupport theChgSupport, int theId, java.lang.String theName, double theDiscourseLo, double theDiscourseHi)
          Create a new continuous variable with the specified universe of discourse.
AbleContinuousVariable(java.lang.String theName, double theDiscourseLo, double theDiscourseHi)
          Create a new continuous variable with the specified universe of discourse.
 
Method Summary
 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.
static java.lang.String Copyright()
          Determine the copyright of this class.
 boolean getBooleanValue()
          Retrieve the value of this data object as a boolean value.
 double getDiscourseHi()
          Retrieve the variable's maximum allowed value..
 double getDiscourseLo()
          Retrieve the variable's minimum allowed value.
 AbleLiteral 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 getInitialValue()
          Retrieve the variable's initial value.
 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 reset()
          Reset the variable to its intial state.
 java.lang.String rlDclString()
          Return a formal rule language "declaration" string that describes this data object.
 void setBooleanValue(boolean theNewValue)
          Set the value of this data object from a boolean value.
 void setDiscourseHi(double theValue)
          Set the variable's maximum allowed value.
 void setDiscourseLo(double theValue)
          Set the variable's minimum allowed value.
 void setFuzzyValue(AbleLiteral 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.
 boolean withinUniverseOfDiscourse(double theValue)
          Determine whether a particular value is within the universe of discourse (between the low and high values inclusive) for this variable.
 java.lang.String xmlCWrString()
          Return a formal XML "clause write" string that describes this data object.
 java.lang.String xmlDclString()
          Return a formal XML "declaration" string that describes this data object.
 
Methods inherited from class com.ibm.able.data.AbleVariable
getChgSupport, getContext, getDataType, getDataTypeAsString, getId, getName, getReferences, getReferent, rlCRdString, setChgSupport, setContext, setId, setReferences, xmlCRdString
 
Methods inherited from class com.ibm.able.data.AbleLhs
asgnEq, asgnIs, asgnIs, cmpIs
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

myDiscourseLo

protected double myDiscourseLo

myDiscourseHi

protected double myDiscourseHi

myValue

protected double myValue

myValueInitial

protected double myValueInitial
Constructor Detail

AbleContinuousVariable

public AbleContinuousVariable(java.lang.Object theContext,
                              java.beans.PropertyChangeSupport theChgSupport,
                              int theId,
                              java.lang.String theName,
                              double theDiscourseLo,
                              double theDiscourseHi)
Create a new continuous variable with the specified universe of discourse.

The initial value of this variable cannot be specified and is set to Double.NaN.

Parameters:
theContext - The context in which this variable resides. May be an Able ruleset, for example, or null if the variable is not part of any context.

theChgSupport - For throwing property change events. This may be null.

theId - The unique Id of the variable.

theName - The unique name of the variable.

theDiscourseLo - The lowest value that this variable may assume.

theDiscourseHi - The highest value that this variable may assume.


AbleContinuousVariable

public AbleContinuousVariable(java.lang.String theName,
                              double theDiscourseLo,
                              double theDiscourseHi)
Create a new continuous variable with the specified universe of discourse.

The initial value of this variable cannot be specified and is set to Double.NaN.

Parameters:
theName - The unique name of the variable.

theDiscourseLo - The lowest value that this variable may assume.

theDiscourseHi - The highest value that this variable may assume.

Method Detail

getBooleanValue

public boolean getBooleanValue()
                        throws AbleDataException
Retrieve the value of this data object as a boolean value.
Returns:
A boolean, if the value of this object can be represented as a boolean value. If the current value is 0.0, false is returned; any other numeric value returns true.
Throws:
AbleDataException - If the value of this object cannot be represented as a boolean value.
Overrides:
getBooleanValue in class AbleLhs

getFuzzyValue

public AbleLiteral getFuzzyValue()
                          throws AbleDataException
Retrieve the value of this data object as a fuzzy value.
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.
Overrides:
getFuzzyValue in class AbleLhs

getGenericValue

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

getNumericValue

public double getNumericValue()
                       throws AbleDataException
Retrieve the value of this data object as a numeric value.
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.
Overrides:
getNumericValue in class AbleLhs

getStringValue

public java.lang.String getStringValue()
                                throws AbleDataException
Retrieve the value of this data object as a string value.
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.
Overrides:
getStringValue in class AbleLhs

getValue

public AbleLiteral getValue()
                     throws AbleDataException
Retrieve the value of this data object as a literal.
Returns:
An AbleNumericLiteral object.
Throws:
AbleDataException - If the value of this object cannot be represented as a literal.
Overrides:
getValue in class AbleLhs

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.

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.
Overrides:
cmpEq in class AbleLhs

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.

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.
Overrides:
cmpGt in class AbleLhs

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.

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.
Overrides:
cmpGtEq in class AbleLhs

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.

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.
Overrides:
cmpLt in class AbleLhs

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.

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.
Overrides:
cmpLtEq in class AbleLhs

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.

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.
Overrides:
cmpNeq in class AbleLhs

setBooleanValue

public void setBooleanValue(boolean theNewValue)
                     throws AbleDataException
Set the value of this data object from a boolean value.
Parameters:
theNewValue - A boolean value. If the new value is true the variable is set to 1.0, but only if that value is within the universe of discourse; if the new value is false the variable is set to 0.0, but only if that value is within the universe of discourse.

Throws:
AbleDataException - If the value of this object cannot be represented as a boolean value.
Overrides:
setBooleanValue in class AbleLhs

setFuzzyValue

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

Throws:
AbleDataException - If the value of this object cannot be represented as a fuzzy value.
Overrides:
setFuzzyValue in class AbleLhs

setGenericValue

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

Throws:
AbleDataException - If the value of this object cannot be derived from the specified Object.
Overrides:
setGenericValue in class AbleLhs

setNumericValue

public void setNumericValue(double theNewValue)
                     throws AbleDataException
Set the value of this data object from a numeric value.
Parameters:
theNewValue - Any number. If the number is not within the universe of discourse for this variable, an exception is thrown.

Throws:
AbleDataException - If the value of this object cannot be represented as a numeric value.
Overrides:
setNumericValue in class AbleLhs

setStringValue

public void setStringValue(java.lang.String theNewValue)
                    throws AbleDataException
Set the value of this data object from a string value.
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 and that number is within the universe of discourse for this variable. otherwise an exception is thrown.

Throws:
AbleDataException - If the value of this object cannot be represented as a string value.
Overrides:
setStringValue in class AbleLhs

setValue

public void setValue(AbleLiteral theNewValue)
              throws AbleDataException
Set the value of this data object from a literal object.
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. The resulting number must be within the universe of discourse for this variable.

Throws:
AbleDataException - If the value of this object cannot be determined from the literal object.
Overrides:
setValue in class AbleLhs

rlDclString

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

xmlDclString

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

xmlCWrString

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

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 AbleVariable

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 AbleVariable

reset

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

getInitialValue

public double getInitialValue()
Retrieve the variable's initial value.

setDiscourseLo

public void setDiscourseLo(double theValue)
Set the variable's minimum allowed value.
Parameters:
theValue - The new minimum value that the variable may assume.


getDiscourseLo

public double getDiscourseLo()
Retrieve the variable's minimum allowed value.

setDiscourseHi

public void setDiscourseHi(double theValue)
Set the variable's maximum allowed value.
Parameters:
theValue - The new maximum value that the variable may assume.


getDiscourseHi

public double getDiscourseHi()
Retrieve the variable's maximum allowed value..

withinUniverseOfDiscourse

public boolean withinUniverseOfDiscourse(double theValue)
Determine whether a particular value is within the universe of discourse (between the low and high values inclusive) for this variable.
Parameters:
theValue - A number to be tested.


toString

public java.lang.String toString()
Retrieve a string describing (the contents of) the object.
Returns:
A String containing the current contents of the object.
Overrides:
toString in class AbleVariable

Copyright

public static java.lang.String Copyright()
Determine the copyright of this class.
Returns:
A String containing this class's copyright statement.

ABLE, Version 1.1b

ABLE: Produced by Joe, Don, and Jeff who say, 'Thanks for your support.'