|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.ibm.icu.util.CharsTrie
public final class CharsTrie
Light-weight, non-const reader class for a CharsTrie. Traverses a char-serialized data structure with minimal state, for mapping strings (16-bit-unit sequences) to non-negative integer values.
This class is not intended for public subclassing.
| Nested Class Summary | |
|---|---|
static class |
CharsTrie.Entry
Return value type for the Iterator. |
static class |
CharsTrie.Iterator
Iterator for all of the (string, value) pairs in a CharsTrie. |
static class |
CharsTrie.State
CharsTrie state object, for saving a trie's current state and resetting the trie back to this state later. |
| Constructor Summary | |
|---|---|
CharsTrie(CharSequence trieChars,
int offset)
Constructs a CharsTrie reader instance. |
|
| Method Summary | |
|---|---|
Object |
clone()
Clones this trie reader object and its state, but not the char array which will be shared. |
BytesTrie.Result |
current()
Determines whether the string so far matches, whether it has a value, and whether another input char can continue a matching string. |
BytesTrie.Result |
first(int inUnit)
Traverses the trie from the initial state for this input char. |
BytesTrie.Result |
firstForCodePoint(int cp)
Traverses the trie from the initial state for the one or two UTF-16 code units for this input code point. |
int |
getNextChars(Appendable out)
Finds each char which continues the string from the current state. |
long |
getUniqueValue()
Determines whether all strings reachable from the current state map to the same value, and if so, returns that value. |
int |
getValue()
Returns a matching string's value if called immediately after current()/first()/next() returned Result.INTERMEDIATE_VALUE or Result.FINAL_VALUE. |
CharsTrie.Iterator |
iterator()
Iterates from the current state of this trie. |
static CharsTrie.Iterator |
iterator(CharSequence trieChars,
int offset,
int maxStringLength)
Iterates from the root of a char-serialized BytesTrie. |
CharsTrie.Iterator |
iterator(int maxStringLength)
Iterates from the current state of this trie. |
BytesTrie.Result |
next(CharSequence s,
int sIndex,
int sLimit)
Traverses the trie from the current state for this string. |
BytesTrie.Result |
next(int inUnit)
Traverses the trie from the current state for this input char. |
BytesTrie.Result |
nextForCodePoint(int cp)
Traverses the trie from the current state for the one or two UTF-16 code units for this input code point. |
CharsTrie |
reset()
Resets this trie to its initial state. |
CharsTrie |
resetToState(CharsTrie.State state)
Resets this trie to the saved state. |
CharsTrie |
saveState(CharsTrie.State state)
Saves the state of this trie. |
| Methods inherited from class java.lang.Object |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public CharsTrie(CharSequence trieChars,
int offset)
The CharSequence must contain a copy of a char sequence from the CharsTrieBuilder, with the offset indicating the first char of that sequence. The CharsTrie object will not read more chars than the CharsTrieBuilder generated in the corresponding build() call.
The CharSequence is not copied/cloned and must not be modified while the CharsTrie object is in use.
trieChars - CharSequence that contains the serialized trie.offset - Root offset of the trie in the CharSequence.| Method Detail |
|---|
public Object clone()
throws CloneNotSupportedException
clone in class ObjectCloneNotSupportedExceptionpublic CharsTrie reset()
public CharsTrie saveState(CharsTrie.State state)
state - The State object to hold the trie's state.
resetToState(com.ibm.icu.util.CharsTrie.State)public CharsTrie resetToState(CharsTrie.State state)
state - The State object which holds a saved trie state.
IllegalArgumentException - if the state object contains no state,
or the state of a different triesaveState(com.ibm.icu.util.CharsTrie.State),
reset()public BytesTrie.Result current()
public BytesTrie.Result first(int inUnit)
inUnit - Input char value. Values below 0 and above 0xffff will never match.
public BytesTrie.Result firstForCodePoint(int cp)
cp - A Unicode code point 0..0x10ffff.
public BytesTrie.Result next(int inUnit)
inUnit - Input char value. Values below 0 and above 0xffff will never match.
public BytesTrie.Result nextForCodePoint(int cp)
cp - A Unicode code point 0..0x10ffff.
public BytesTrie.Result next(CharSequence s,
int sIndex,
int sLimit)
Result result=current(); for(each c in s) if(!result.hasNext()) return Result.NO_MATCH; result=next(c); return result;
s - Contains a string.sIndex - The start index of the string in s.sLimit - The (exclusive) end index of the string in s.
public int getValue()
public long getUniqueValue()
public int getNextChars(Appendable out)
out - Each next char is appended to this object.
(Only uses the out.append(c) method.)
public CharsTrie.Iterator iterator()
iterator in interface Iterable<CharsTrie.Entry>public CharsTrie.Iterator iterator(int maxStringLength)
maxStringLength - If 0, the iterator returns full strings.
Otherwise, the iterator returns strings with this maximum length.
public static CharsTrie.Iterator iterator(CharSequence trieChars,
int offset,
int maxStringLength)
trieChars - CharSequence that contains the serialized trie.offset - Root offset of the trie in the CharSequence.maxStringLength - If 0, the iterator returns full strings.
Otherwise, the iterator returns strings with this maximum length.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||