Package edu.hws.jcm.data

# Class SymbolTable

java.lang.Object
edu.hws.jcm.data.SymbolTable

All Implemented Interfaces:
  `Serializable`

public class SymbolTable extends Object implements Serializable
A symbol table contains MathObjects, associating them with their names. To support scoping (for example), a symbol table can have a parent symbol table. If a symbol is not found in the table itself, the search procedes to its parent. MathObjects in the parent are hidden by MathObjects of the same name in a SymbolTable. Note that a NullPointerException error will occur if an attempt is made to add a MathObject with a null name to a SymbolTable. A MathObject should not be renamed while it is registered in a SymbolTable. Note that a Parser has an associated SymbolTable. I expect SymbolTables to be used only through Parsers.

See Also:
  - Serialized Form

## Method Summary

Modifier and Type
Method
Description
`void`
`add(MathObject sym)`
Adds sym to the SymbolTable, associating it with its name.
`void`
`add(String name, MathObject sym)`
Adds the given MathObject, sym, to the symbol table, associating it with the given name (which is probably the name of the symbol or that name transformed to lower case, but it doesn't have to be).
`MathObject`
`get(String name)`
Look up the object with the given name, if any.
`void`
`remove(String name)`
Remove the object with the given name from the symbol table, but NOT from the parent symbol table.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### get

public MathObject get(String name)
Look up the object with the given name, if any. If not found, return null. (If the name is not found in the HashTable, symbols, the search is delegated to the parent.) If the name is null, then null is returned.

### add

public void add(MathObject sym)
Adds sym to the SymbolTable, associating it with its name.

### add

public void add(String name, MathObject sym)
Adds the given MathObject, sym, to the symbol table, associating it with the given name (which is probably the name of the symbol or that name transformed to lower case, but it doesn't have to be). If the same name is already in use in the HashTable then the new object replaces the current object. Note that if the name is defined in the parent symbol table, then the old object is hidden, not removed from the parent. If sym is null or if sym's name is null, than a NullPointerException is thrown.

### remove

public void remove(String name)
Remove the object with the given name from the symbol table, but NOT from the parent symbol table. No error occurs if the name is not in the table or if name is null. If an object of the same name occurs in the parent, this routine will un-hide it.