|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.Dictionary
java.util.Hashtable
org.nfunk.jep.SymbolTable
A Hashtable which holds a list of all variables.
Hevily changed from Jep-2.24 which was just a Hashtable which stored
the values of each variable. Here the Hashtable contains
elements of type Variable
which contain
information about that variable.
Rather than using get
the methods
getValue(String)
, getVar(String)
should be used to return the value or variable.
The put
method is deprecated and should be replace by one of
addVariable(String,Object)
adds a variable with a given name and value, returns null if variable already exists.
addConstant(String,Object)
adds a 'constant' variable whos value cannot be changed.
setVarValue(String,Object)
sets the value of an existing variable. Returns false if variable does not exist.
makeVarIfNeeded(String,Object)
if necessary creates a variable and set its value.
makeVarIfNeeded(String)
if necessary creates a variable. Does not change the value.
Variables which do not have a value set are deamed to be invalid.
When Variables need to be constructed then methods in the VariableFactory
should be called, which allows different types of variables to be used.
Field Summary | |
protected VariableFactory |
vf
|
Constructor Summary | |
SymbolTable(VariableFactory varFac)
SymbolTable should always be constructed an associated variable factory. |
Method Summary | |
Variable |
addConstant(java.lang.String name,
java.lang.Object val)
Create a constant variable with the given name and value. |
Variable |
addVariable(java.lang.String name,
java.lang.Object val)
Creates a variable with given value. |
void |
clearValues()
Clears the values of all variables. |
java.lang.Object |
get(java.lang.Object key)
Deprecated. The getValue or getVar methods should be used instead. |
java.lang.Object |
getValue(java.lang.Object key)
Finds the value of the variable with the given name. |
Variable |
getVar(java.lang.String name)
Finds the variable with given name. |
VariableFactory |
getVariableFactory()
Returns the variable factory of this instance. |
Variable |
makeVarIfNeeded(java.lang.String name)
If necessary create a variable with the given name. |
Variable |
makeVarIfNeeded(java.lang.String name,
java.lang.Object val)
Create a variable with the given name and value. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object val)
Deprecated. The setVarValue or makeVar methods should be used instead. |
boolean |
setVarValue(java.lang.String name,
java.lang.Object val)
Sets the value of variable with the given name. |
java.lang.String |
toString()
Returns a list of variables, one per line. |
Methods inherited from class java.util.Hashtable |
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, hashCode, isEmpty, keys, keySet, putAll, rehash, remove, size, values |
Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
protected VariableFactory vf
Constructor Detail |
public SymbolTable(VariableFactory varFac)
Method Detail |
public java.lang.Object get(java.lang.Object key)
public java.lang.Object getValue(java.lang.Object key)
public Variable getVar(java.lang.String name)
public java.lang.Object put(java.lang.Object key, java.lang.Object val)
public boolean setVarValue(java.lang.String name, java.lang.Object val)
public Variable addVariable(java.lang.String name, java.lang.Object val)
public Variable addConstant(java.lang.String name, java.lang.Object val)
public Variable makeVarIfNeeded(java.lang.String name, java.lang.Object val)
public Variable makeVarIfNeeded(java.lang.String name)
public java.lang.String toString()
public void clearValues()
Variable.setValidValue
method.
public VariableFactory getVariableFactory()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |