org.nfunk.jep
Class SymbolTable

java.lang.Object
  extended byjava.util.Dictionary
      extended byjava.util.Hashtable
          extended byorg.nfunk.jep.SymbolTable
All Implemented Interfaces:
java.lang.Cloneable, java.util.Map, java.io.Serializable
Direct Known Subclasses:
XSymbolTable

public class SymbolTable
extends java.util.Hashtable

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

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.

Author:
Rich Morris Created on 28-Feb-2004
See Also:
Serialized Form

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

vf

protected VariableFactory vf
Constructor Detail

SymbolTable

public SymbolTable(VariableFactory varFac)
SymbolTable should always be constructed an associated variable factory.

Method Detail

get

public java.lang.Object get(java.lang.Object key)
Deprecated. The getValue or getVar methods should be used instead.


getValue

public java.lang.Object getValue(java.lang.Object key)
Finds the value of the variable with the given name. Returns null if variable does not exist.


getVar

public Variable getVar(java.lang.String name)
Finds the variable with given name. Returns null if variable does not exist.


put

public java.lang.Object put(java.lang.Object key,
                            java.lang.Object val)
Deprecated. The setVarValue or makeVar methods should be used instead.


setVarValue

public boolean setVarValue(java.lang.String name,
                           java.lang.Object val)
Sets the value of variable with the given name. Returns false if variable does not exist or if its value cannot be set.


addVariable

public Variable addVariable(java.lang.String name,
                            java.lang.Object val)
Creates a variable with given value. Returns null if variable already exists.


addConstant

public Variable addConstant(java.lang.String name,
                            java.lang.Object val)
Create a constant variable with the given name and value. Returns null if variable already exists.


makeVarIfNeeded

public Variable makeVarIfNeeded(java.lang.String name,
                                java.lang.Object val)
Create a variable with the given name and value. It siliently does nothing if the value cannot be set.

Returns:
the Variable.

makeVarIfNeeded

public Variable makeVarIfNeeded(java.lang.String name)
If necessary create a variable with the given name. If the variable exists its value will not be changed.

Returns:
the Variable.

toString

public java.lang.String toString()
Returns a list of variables, one per line.


clearValues

public void clearValues()
Clears the values of all variables. Finer control is available through the Variable.setValidValue method.


getVariableFactory

public VariableFactory getVariableFactory()
Returns the variable factory of this instance.



http://www.singularsys.com/jep Copyright © 2004 Singular Systems