|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.norecess.citkit.symboltable.EmptySymbolTable<T>
public class EmptySymbolTable<T>
This class allows other symbol-table implementations to avoid
null checks. Think of this class like a header node in a linked
list: it exists to make certain algorithms a bit cleaner, but you don't
actually store any useful information in it.
Do not bother creating your own instances of this class. A good
SymbolTable implementation will use this class automatically (e.g.,
HashSymbolTable.HashSymbolTable() does).
| Constructor Summary | |
|---|---|
EmptySymbolTable()
Standard constructor. |
|
| Method Summary | |
|---|---|
void |
add(java.lang.String name,
T value)
Always throws an exception. |
void |
add(Symbol variable,
T value)
Always throws an exception. |
boolean |
equals(java.lang.Object other)
|
T |
get(ISymbol variable)
For this implementation, this method always returns null
since the variable is not found. |
T |
get(java.lang.String name)
Always returns null. |
java.util.Set<Symbol> |
getSymbols()
Returns an empty list of symbols since there are no symbols in an empty symbol table. |
java.lang.String |
getVariablesAsString()
Returns an empty string since an empty symbol table has no variables to turn into a string. |
int |
hashCode()
|
T |
set(java.lang.String name,
T value)
Returns null. |
T |
set(Symbol variable,
T value)
Based on previous implementations, this method returns null. |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public EmptySymbolTable()
| Method Detail |
|---|
public boolean equals(java.lang.Object other)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object
public void add(Symbol variable,
T value)
null reference for the previous symbol table, and you would
get NullPointerExceptions instead.
add in interface SymbolTable<T>variable - the new variable to add to the symbol table.value - the new value to associate with the new variable.
java.lang.IllegalStateException - always throws this exception because it keeps no state
information.
public void add(java.lang.String name,
T value)
add in interface SymbolTable<T>add(Symbol, Object)public T get(ISymbol variable)
null
since the variable is not found.
get in interface SymbolTable<T>variable - the name of the variable which won't be found.
nullpublic T get(java.lang.String name)
null.
get in interface SymbolTable<T>get(ISymbol)public java.util.Set<Symbol> getSymbols()
getSymbols in interface SymbolTable<T>public java.lang.String getVariablesAsString()
getVariablesAsString in interface SymbolTable<T>
public T set(Symbol variable,
T value)
null.
This can be construed as misleading since the variable was never defined,
and no value has been changed.
set in interface SymbolTable<T>variable - the variable that was never defined.value - the new value that will be ignored.
null.
public T set(java.lang.String name,
T value)
null.
set in interface SymbolTable<T>set(Symbol, Object)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||