|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
public interface SymbolTable
Interface mapping symbols as strings to integer identifiers and vice-versa. In addition to the mapping, the symbol table provides interfaces for optional operations of removing a symbol or clearing the entire symbol, as well as adding a symbol to the table.
| Field Summary | |
|---|---|
static int |
UNKNOWN_SYMBOL_ID
The value returned for a symbol that is not in the symbol table, namely -1. |
| Method Summary | |
|---|---|
void |
clear()
Removes all the symbols from the symbol table. |
int |
getOrAddSymbol(String symbol)
Returns the identifier for the specified symbol. |
String |
idToSymbol(int id)
Return the symbol corresponding to the specified identifier. |
int |
numSymbols()
Returns the number of symbols in this symbol table. |
int |
removeSymbol(String symbol)
Removes the specified symbol from the symbol table if it was in the table and returns its identifier. |
int |
symbolToID(String symbol)
Return the identifier corresponding to the specified symbol, -1 if the symbol does not exist. |
| Field Detail |
|---|
static final int UNKNOWN_SYMBOL_ID
-1.
| Method Detail |
|---|
int symbolToID(String symbol)
-1 if the symbol does not exist. The constant
-1 is available as the value of UNKNOWN_SYMBOL_ID.
symbol - Symbol whose identifier is returned.
-1 if the symbol does not exist.String idToSymbol(int id)
0 and the
number of symbols in the table minus one, inclusive. Raises an
index out of bounds exception for identifiers out of range.
id - Identifier whose symbol is returned.
IndexOutOfBoundsException - If there is no symbol for the
specified identifier.int numSymbols()
int getOrAddSymbol(String symbol)
symbol - Symbol whose identifier is returned.
UnsupportedOperationException - If this operation is not
supproted.int removeSymbol(String symbol)
-1, or
UNKNOWN_SYMBOL_ID is returned. Optional operation.
symbol - Symbol to remove.
-1 if it didn't exist.
UnsupportedOperationException - If this operation is
not supported by this implementation.void clear()
If an implementing class does not allow removal, it may throw an unsupported operation exception for this method. OPtional operationl.
UnsupportedOperationException - If this operation is
not supported by this implementation.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||