ABLE, Version 1.1b

com.ibm.able.beans.rules
Class AbleRuleVariable

java.lang.Object
  |
  +--com.ibm.able.beans.AbleAtom
        |
        +--com.ibm.able.beans.rules.AbleRuleVariable

public class AbleRuleVariable
extends AbleAtom
implements java.io.Serializable

A Variable can hold a value and can appear on the lefthand and righthand side of clauses.

Version:
1.0.0; change log:
 Version   Description
 --------  -----------
 1.0.0     Initial release.

 
See Also:
Serialized Form

Field Summary
protected  java.util.Vector clauseRefs
          clauseRefs is a list of clauses that reference this variable.
 
Fields inherited from class com.ibm.able.beans.AbleAtom
name, value
 
Constructor Summary
AbleRuleVariable(java.lang.String theName)
          Create a new variable with the specified name.
AbleRuleVariable(java.lang.String theName, boolean theInitValue)
          Create a new variable with the specified name and initial boolean value.
AbleRuleVariable(java.lang.String theName, double theInitValue)
          Create a new variable with the specified name and initial numeric value.
AbleRuleVariable(java.lang.String theName, double theLoValue, double theHiValue)
          Create a new variable with the specified name and continuous numeric range.
AbleRuleVariable(java.lang.String theName, java.lang.String theSymbolList)
          Create a new variable with the specified name and categorical labels.
 
Method Summary
 void addClauseRef(AbleClause aClauseReference)
          Register a clause which refers to this variable.
 void addClauseRef(AbleConsequentClause aClauseReference)
          Register a clause which refers to this variable.
 void askUser()
           
 java.util.Vector getClauseRefs()
          Retrieve a list of clauses that refer to this variable.
 int getIndex(java.lang.String aLabel)
          Retrieve the index of the specified label.
 java.lang.String getLabel(int anIndex)
          Retrieve the label with the specified index.
 java.lang.String getLabels()
          Retrieve a string containing all the labels for this variable.
 java.lang.String getStringValue()
          Retrieve the current value of this variable.
 java.lang.Object getValue()
          Retrieve the current value of this variable.
 boolean isCategorical()
          Determine whether this variable is a categorical variable.
 void reset()
          Reset the variable to its initial state.
 java.lang.String rlString()
          Return a formal rule language string.
 void setLabels(java.lang.String newLabels)
          Specify a set of textual labels which can be used to refer to the various values of this variable.
 void setPromptText(java.lang.String aPrompt)
          Set prompt text for this variable that can be used to query the end-user for a new value for this variable.
 void setRuleName(java.lang.String aRuleName)
          Set a rulename for this variable.
 void setValue(java.lang.Object aValue)
          Set the value of this variable.
 java.lang.String toString()
           
 void updateClauses()
          Re-evaluate each clause that refers to this variable with the side effect that each clause's truth value is updated.
 java.lang.String xmlString()
          Return a formal XML string.
 
Methods inherited from class com.ibm.able.beans.AbleAtom
getName
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

clauseRefs

protected java.util.Vector clauseRefs
clauseRefs is a list of clauses that reference this variable.
Constructor Detail

AbleRuleVariable

public AbleRuleVariable(java.lang.String theName)
Create a new variable with the specified name.

AbleRuleVariable

public AbleRuleVariable(java.lang.String theName,
                        boolean theInitValue)
Create a new variable with the specified name and initial boolean value.

AbleRuleVariable

public AbleRuleVariable(java.lang.String theName,
                        double theLoValue,
                        double theHiValue)
Create a new variable with the specified name and continuous numeric range.

AbleRuleVariable

public AbleRuleVariable(java.lang.String theName,
                        double theInitValue)
Create a new variable with the specified name and initial numeric value.

AbleRuleVariable

public AbleRuleVariable(java.lang.String theName,
                        java.lang.String theSymbolList)
Create a new variable with the specified name and categorical labels.
Method Detail

setValue

public void setValue(java.lang.Object aValue)
Set the value of this variable. A side-effect is that all clauses the reference this variable are re-evaluated and their truth values updated.
Parameters:
aValue - Any arbitrary object that represents the value of this variable.


getValue

public java.lang.Object getValue()
Retrieve the current value of this variable.
Returns:
An object that represents the value of this variable.
Overrides:
getValue in class AbleAtom

getStringValue

public java.lang.String getStringValue()
Retrieve the current value of this variable.
Returns:
A String object that represents the value of this variable.

setLabels

public void setLabels(java.lang.String newLabels)
Specify a set of textual labels which can be used to refer to the various values of this variable. Note: Setting this list makes the variable categorical.
Parameters:
newLabels - A string of blank delimited words, each of which represents a label for a particular value of the variable.


getLabels

public java.lang.String getLabels()
Retrieve a string containing all the labels for this variable.
Returns:
A string of blank delimited words, each word representing a label for a particular value of this variable.

getLabel

public java.lang.String getLabel(int anIndex)
Retrieve the label with the specified index.
Parameters:
anIndex - A zero-based index into the list of labels.

Returns:
The label at the specified index. If there is no label at the specified index, an exception is thrown.

getIndex

public int getIndex(java.lang.String aLabel)
Retrieve the index of the specified label.
Parameters:
aLabel - A string representing a label for a value of this variable.

Returns:
The zero-based index of the specified label, or -1 if the label is not found in the list of labels.

isCategorical

public boolean isCategorical()
Determine whether this variable is a categorical variable.
Returns:
true if the variable is categorical, false otherwise.

addClauseRef

public void addClauseRef(AbleClause aClauseReference)
Register a clause which refers to this variable.
Parameters:
aClauseReference - A clause object which refers to this variable.


addClauseRef

public void addClauseRef(AbleConsequentClause aClauseReference)
Register a clause which refers to this variable.
Parameters:
aClauseReference - A consequent clause object which refers to this variable.


getClauseRefs

public java.util.Vector getClauseRefs()
Retrieve a list of clauses that refer to this variable.
Returns:
A list of clauses that have been registered as referring to this variable.

updateClauses

public void updateClauses()
Re-evaluate each clause that refers to this variable with the side effect that each clause's truth value is updated. This method is called whenever a new value is assigned to the variable.

setRuleName

public void setRuleName(java.lang.String aRuleName)
Set a rulename for this variable.
Parameters:
aRuleName - Any arbitrary string.

Returns:
void.

setPromptText

public void setPromptText(java.lang.String aPrompt)
Set prompt text for this variable that can be used to query the end-user for a new value for this variable.
Parameters:
aPrompt - Any arbitrary string.

Returns:
void.

toString

public java.lang.String toString()
Overrides:
toString in class AbleAtom

askUser

public void askUser()

reset

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

rlString

public java.lang.String rlString()
Return a formal rule language string.
Returns:
A String describing the object in rule language.


xmlString

public java.lang.String xmlString()
Return a formal XML string.
Returns:
A String describing the object in XML.


ABLE, Version 1.1b

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