|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ctc.wstx.util.WordResolver
public final class WordResolver
A specialized Map/Symbol table - like data structure that can be used for both checking whether a word (passed in as a char array) exists in certain set of words AND getting that word as a String. It is reasonably efficient both time and speed-wise, at least for certain use cases; specifically, if there is no existing key to use, it is more efficient way to get to a shared copy of that String The general usage pattern is expected to be such that most checks are positive, ie. that the word indeed is contained in the structure.
Although this is an efficient data struct for specific set of usage patterns, one restriction is that the full set of words to include has to be known before constructing the instnace. Also, the size of the set is limited to total word content of about 20k characters.
TODO: Should document the internal data structure...
Field Summary | |
---|---|
static int |
MAX_WORDS
Maximum number of words (Strings) an instance can contain |
Method Summary | |
---|---|
static WordResolver |
constructInstance(java.util.TreeSet wordSet)
Tries to construct an instance given ordered set of words. |
java.lang.String |
find(char[] str,
int start,
int end)
|
java.lang.String |
find(java.lang.String str)
|
int |
size()
|
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int MAX_WORDS
Method Detail |
---|
public static WordResolver constructInstance(java.util.TreeSet wordSet)
Note: currently maximum number of words that can be contained
is limited to MAX_WORDS
; additionally, maximum length
of all such words can not exceed roughly 28000 characters.
public int size()
public java.lang.String find(char[] str, int start, int end)
str
- Character array that contains the word to findstart
- Index of the first character of the wordend
- Index following the last character of the word,
so that end - start
equals word length (similar
to the way String.substring()
has).
public java.lang.String find(java.lang.String str)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |