| java.lang.Object com.sun.xml.stream.xerces.util.SymbolTable
All known Subclasses: com.sun.xml.stream.xerces.util.SynchronizedSymbolTable, com.sun.xml.stream.xerces.util.ShadowedSymbolTable,
SymbolTable | public class SymbolTable (Code) | | This class is a symbol table implementation that guarantees that
strings used as identifiers are unique references. Multiple calls
to addSymbol will always return the same string
reference.
The symbol table performs the same task as String.intern()
with the following differences:
-
A new string object does not need to be created in order to
retrieve a unique reference. Symbols can be added by using
a series of characters in a character array.
-
Users of the symbol table can provide their own symbol hashing
implementation. For example, a simple string hashing algorithm
may fail to produce a balanced set of hashcodes for symbols
that are mostly unique. Strings with similar leading
characters are especially prone to this poor hashing behavior.
See Also: SymbolHash author: Andy Clark version: $Id: SymbolTable.java,v 1.2 2006/04/01 06:01:41 jeffsuttor Exp $ |
Inner Class :final protected static class Entry | |
Constructor Summary | |
public | SymbolTable() Constructs a symbol table with a default number of buckets. | public | SymbolTable(int tableSize) Constructs a symbol table with a specified number of buckets. |
Method Summary | |
public String | addSymbol(String symbol) Adds the specified symbol to the symbol table and returns a
reference to the unique symbol. | public String | addSymbol(char[] buffer, int offset, int length) Adds the specified symbol to the symbol table and returns a
reference to the unique symbol. | public boolean | containsSymbol(String symbol) Returns true if the symbol table already contains the specified
symbol. | public boolean | containsSymbol(char[] buffer, int offset, int length) Returns true if the symbol table already contains the specified
symbol. | public char[] | getCharArray() Return previously retrieved symbol as character array. | public int | hash(String symbol) Returns a hashcode value for the specified symbol. | public int | hash(char[] buffer, int offset, int length) Returns a hashcode value for the specified symbol information. |
TABLE_SIZE | final protected static int TABLE_SIZE(Code) | | Default table size.
|
fBuckets | protected Entry[] fBuckets(Code) | | Buckets.
|
fTableSize | protected int fTableSize(Code) | | |
symbolAsArray | protected char[] symbolAsArray(Code) | | |
SymbolTable | public SymbolTable()(Code) | | Constructs a symbol table with a default number of buckets.
|
SymbolTable | public SymbolTable(int tableSize)(Code) | | Constructs a symbol table with a specified number of buckets.
|
addSymbol | public String addSymbol(String symbol)(Code) | | Adds the specified symbol to the symbol table and returns a
reference to the unique symbol. If the symbol already exists,
the previous symbol reference is returned instead, in order
guarantee that symbol references remain unique.
Parameters: symbol - The new symbol. |
addSymbol | public String addSymbol(char[] buffer, int offset, int length)(Code) | | Adds the specified symbol to the symbol table and returns a
reference to the unique symbol. If the symbol already exists,
the previous symbol reference is returned instead, in order
guarantee that symbol references remain unique.
Parameters: buffer - The buffer containing the new symbol. Parameters: offset - The offset into the buffer of the new symbol. Parameters: length - The length of the new symbol in the buffer. |
containsSymbol | public boolean containsSymbol(String symbol)(Code) | | Returns true if the symbol table already contains the specified
symbol.
Parameters: symbol - The symbol to look for. |
containsSymbol | public boolean containsSymbol(char[] buffer, int offset, int length)(Code) | | Returns true if the symbol table already contains the specified
symbol.
Parameters: buffer - The buffer containing the symbol to look for. Parameters: offset - The offset into the buffer. Parameters: length - The length of the symbol in the buffer. |
getCharArray | public char[] getCharArray()(Code) | | Return previously retrieved symbol as character array.
|
hash | public int hash(String symbol)(Code) | | Returns a hashcode value for the specified symbol. The value
returned by this method must be identical to the value returned
by the hash(char[],int,int) method when called
with the character array that comprises the symbol string.
Parameters: symbol - The symbol to hash. |
hash | public int hash(char[] buffer, int offset, int length)(Code) | | Returns a hashcode value for the specified symbol information.
The value returned by this method must be identical to the value
returned by the hash(String) method when called
with the string object created from the symbol information.
Parameters: buffer - The character buffer containing the symbol. Parameters: offset - The offset into the character buffer of the startof the symbol. Parameters: length - The length of the symbol. |
|
|