|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.uima.internal.util.SymbolTable
public class SymbolTable
The SymbolTable class provides a generic symbol table. A symbol table is a bijective mapping between strings and integers. Symbol numbering starts at a point defined by the user, which is 0 by default. A SymbolTable provides quick access to symbol numbers (code points) through a hash table. The reverse map is facilitated through a separate vector of the symbols. This is memory intensive, but much faster than searching through the hashtable.
Constructor Summary | |
---|---|
SymbolTable()
Default constructor |
|
SymbolTable(int start)
Use this constructor if you need your symbol numbering to start at a different point than 0. |
|
SymbolTable(java.lang.String[] names)
Init the symbol table from an array of strings, where code points correspond to array positions. |
Method Summary | |
---|---|
boolean |
contains(java.lang.String symbol)
|
SymbolTable |
copy()
Perform a deep copy. |
int |
get(java.lang.String symbol)
Get value of symbol in table. |
int |
getStart()
Get the starting number of the symbol table. |
java.lang.String |
getSymbol(int i)
Find the symbol corresponding to a value. |
static SymbolTable |
readFromFile(java.lang.String filename)
Read a file line by line, and create an entry for each line. |
int |
set(java.lang.String symbol)
Create new symbol in table. |
int |
size()
Returns number of symbols in table. |
java.lang.String |
toString()
Returns the string representation of the internal hash table. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public SymbolTable(int start)
start
- The code point of the first symbol added to the table. Subsequent symbols will have
larger code points.public SymbolTable()
public SymbolTable(java.lang.String[] names)
names
- The String array containing the symbols.Method Detail |
---|
public boolean contains(java.lang.String symbol)
public int getStart()
public SymbolTable copy()
this
.public int set(java.lang.String symbol)
symbol
- the input string to be put in the table.
public int get(java.lang.String symbol)
symbol
- the input string.
start-1
, else
(where start
is the code point of the first symbol).public java.lang.String getSymbol(int i)
i
- the number that we want to get the string value for.
public int size()
public java.lang.String toString()
toString
in class java.lang.Object
public static SymbolTable readFromFile(java.lang.String filename) throws java.io.IOException
filename
- The name of the file to be read in.
java.io.IOException
- Errors reading in the file.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |