|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectcom.aliasi.symbol.MapSymbolTable
public class MapSymbolTable
A MapSymbolTable is a dynamic symbol table based on a
pair of underlying maps. After creating a map symbol table, new
symbols may be added using getOrAddSymbol(String).
Map symbol tables are serializable. The result of writing
to an object output stream and reading back in through an
object input stream produces an instance of this same class,
MapSymbolTable, with the same behavior as the
instance serialized.
Implementation Note: This table uses a pair of
maps, one in each direction between symbols represented
by instances of String and identifiers
represented by instance of Integer.
| Field Summary |
|---|
| Fields inherited from interface com.aliasi.symbol.SymbolTable |
|---|
UNKNOWN_SYMBOL_ID |
| Constructor Summary | |
|---|---|
MapSymbolTable()
Construct an empty map symbol table. |
|
MapSymbolTable(int firstId)
Construct an empty map symbol table that begins allocating identifiers at the specified value. |
|
MapSymbolTable(Map<String,Integer> symbolToIdMap)
Construct a map symbol which associates symbols to identifiers based on the specified map. |
|
| Method Summary | |
|---|---|
void |
clear()
Clears all of the symbols from the symbol table. |
void |
compileTo(ObjectOutput objOut)
Deprecated. As of LingPipe 3.1, use objOut.writeObject(this). |
int |
getOrAddSymbol(String symbol)
Returns the identifier for the specified symbol, adding it to the symbol table if necessary. |
Integer |
getOrAddSymbolInteger(String symbol)
Returns the integer identifier for the specified symbol, adding it to the symbol table if necessary. |
Set<Integer> |
idSet()
Returns the complete set of ids in this symbol table. |
String |
idToSymbol(int id)
Return the symbol corresponding to the specified identifier. |
String |
idToSymbol(Integer id)
Returns the symbol for 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. |
Set<String> |
symbolSet()
Returns the complete set of symbols in this symbol table. |
int |
symbolToID(String symbol)
Return the identifier corresponding to the specified symbol, -1 if the symbol does not exist. |
Integer |
symbolToIDInteger(String symbol)
Returns an Integer representation of the symbol if it exists in the table or null if it does not. |
String |
toString()
Returns a string-based representation of this symbol table by printing the underlying identifier to symbol mapping. |
static SymbolTable |
unmodifiableView(SymbolTable table)
Returns a view of the specified symbol table that cannot be modified. |
void |
writeTo(ObjectOutput objOut)
Deprecated. As of LingPipe 3.1, use objOut.writeObject(this). |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public MapSymbolTable()
0) and subsequent
symbols are assigned successive integer identifiers.
public MapSymbolTable(int firstId)
firstId - Identifier of first symbol.public MapSymbolTable(Map<String,Integer> symbolToIdMap)
symbolToIdMap - A map from symbols to identifiers.
IllegalArgumentException - If two distinct symbols map to
the same identifier, or if the unknown symbol identifier, SymbolTable.UNKNOWN_SYMBOL_ID, is used as an identifier.| Method Detail |
|---|
public Set<Integer> idSet()
public Set<String> symbolSet()
@Deprecated
public void writeTo(ObjectOutput objOut)
throws IOException
objOut.writeObject(this).
MapSymbolTable with the same entries as this symbol
table.
Calling this method, writeTo(objOut) produces
the same result as standard serialization,
objOut.writeObject(this). This method has been
deprecated in favor of standard serialization.
objOut - Object output to which to write this symbol
table.
IOException - If there is an I/O error writing.
@Deprecated
public void compileTo(ObjectOutput objOut)
throws IOException
objOut.writeObject(this).
MapSymbolTable with the same entries as this symbol
table, so this is in some sense a no-op compilation.
Calling this method, compileTo(objOut) produces
the same result as standard serialization,
objOut.writeObject(this). This method has been
deprecated in favor of standard serialization.
compileTo in interface CompilableobjOut - Object output to which to write this symbol
table.
IOException - If there is an I/O error writing.public int numSymbols()
SymbolTable
numSymbols in interface SymbolTablepublic int symbolToID(String symbol)
SymbolTable-1 if the symbol does not exist. The constant
-1 is available as the value of SymbolTable.UNKNOWN_SYMBOL_ID.
symbolToID in interface SymbolTablesymbol - Symbol whose identifier is returned.
-1 if the symbol does not exist.public Integer symbolToIDInteger(String symbol)
symbol - Symbol whose identifer is returned.
public String idToSymbol(Integer id)
id - Integer identifier.
IndexOutOfBoundsException - If the symbol could
not be found in the symbol table.public String idToSymbol(int id)
SymbolTable0 and the
number of symbols in the table minus one, inclusive. Raises an
index out of bounds exception for identifiers out of range.
idToSymbol in interface SymbolTableid - Identifier whose symbol is returned.
public int removeSymbol(String symbol)
removeSymbol in interface SymbolTablesymbol - Symbol to remove.
public void clear()
clear in interface SymbolTablepublic int getOrAddSymbol(String symbol)
getOrAddSymbol in interface SymbolTablesymbol - Symbol to get or add to the table.
public Integer getOrAddSymbolInteger(String symbol)
symbol - Symbol to get or add to the table.
public String toString()
toString in class Objectpublic static SymbolTable unmodifiableView(SymbolTable table)
clear(), getOrAddSymbol(String),
and removeSymbol(String) will throw unsupported operation
exceptions when called. The remaining methods will delegate to
the specified table, to which the returned view holds a reference.
The unmodifiable view is serializable if the underlying symbol table is serializable. The symbol table read back in will also be unmodifiable.
table - Table a view of which is returned.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||