|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.util.Observable org.nfunk.jep.Variable
public class Variable
Information about a variable. Each variable has a name, a value. There is a flag to indicate whether it is a constant or not (constants cannot have their value changed). There is also a flag to indicate whether the value of the variable is valid, if the variable is initialised without a value then its value is said to be invalid.
Field Summary | |
---|---|
protected java.lang.String |
name
|
Constructor Summary | |
---|---|
protected |
Variable(java.lang.String name)
Constructors are protected. |
protected |
Variable(java.lang.String name,
java.lang.Object value)
Constructors are protected. |
Method Summary | |
---|---|
java.lang.String |
getName()
|
java.lang.Object |
getValue()
|
boolean |
hasValidValue()
Is the value of this variable valid? |
boolean |
isConstant()
|
void |
setIsConstant(boolean b)
|
void |
setValidValue(boolean val)
Sets whether the value of variable is valid. |
boolean |
setValue(java.lang.Object object)
Sets the value of the variable. |
protected boolean |
setValueRaw(java.lang.Object object)
In general subclasses should override this method rather than setValue. |
java.lang.String |
toString()
Returns a string with the variable name followed by it's value. |
Methods inherited from class java.util.Observable |
---|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers, setChanged |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected java.lang.String name
Constructor Detail |
---|
protected Variable(java.lang.String name)
VariableFactory
which are in turned called by SymbolTable
.
protected Variable(java.lang.String name, java.lang.Object value)
VariableFactory
which are in turned called by SymbolTable
.
Method Detail |
---|
public java.lang.String getName()
public boolean isConstant()
public void setIsConstant(boolean b)
public java.lang.Object getValue()
public boolean hasValidValue()
public void setValidValue(boolean val)
public boolean setValue(java.lang.Object object)
This method call java.util.Observable.notifyObservers() to indicate to anyone interested that the value has been changed. Note subclasses should override setValueRaw rather than this method so they do not need to handle the Observable methods.
protected boolean setValueRaw(java.lang.Object object)
object
-
public java.lang.String toString()
a: 10If the variable is a constant the string " (Constant" is appended.
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |