public abstract class Trie2 extends Object implements Iterable<Trie2.Range>
| Modifier and Type | Class and Description |
|---|---|
class |
Trie2.CharSequenceIterator
An iterator that operates over an input CharSequence, and for each Unicode code point
in the input returns the associated value from the Trie2.
|
static class |
Trie2.CharSequenceValues
Struct-like class for holding the results returned by a UTrie2 CharSequence iterator.
|
static class |
Trie2.Range
When iterating over the contents of a Trie2, Elements of this type are produced.
|
static interface |
Trie2.ValueMapper
When iterating over the contents of a Trie2, an instance of TrieValueMapper may
be used to remap the values from the Trie2.
|
| Constructor and Description |
|---|
Trie2() |
| Modifier and Type | Method and Description |
|---|---|
Trie2.CharSequenceIterator |
charSequenceIterator(CharSequence text,
int index)
Create an iterator that will produce the values from the Trie2 for
the sequence of code points in an input text.
|
static Trie2 |
createFromSerialized(ByteBuffer bytes)
Create a Trie2 from its serialized form.
|
boolean |
equals(Object other)
Equals function.
|
abstract int |
get(int codePoint)
Get the value for a code point as stored in the Trie2.
|
abstract int |
getFromU16SingleLead(char c)
Get the trie value for a UTF-16 code unit.
|
static int |
getVersion(InputStream is,
boolean littleEndianOk)
Get the UTrie version from an InputStream containing the serialized form
of either a Trie (version 1) or a Trie2 (version 2).
|
int |
hashCode() |
Iterator<Trie2.Range> |
iterator()
Create an iterator over the value ranges in this Trie2.
|
Iterator<Trie2.Range> |
iterator(Trie2.ValueMapper mapper)
Create an iterator over the value ranges from this Trie2.
|
Iterator<Trie2.Range> |
iteratorForLeadSurrogate(char lead)
Create an iterator over the Trie2 values for the 1024=0x400 code points
corresponding to a given lead surrogate.
|
Iterator<Trie2.Range> |
iteratorForLeadSurrogate(char lead,
Trie2.ValueMapper mapper)
Create an iterator over the Trie2 values for the 1024=0x400 code points
corresponding to a given lead surrogate.
|
protected int |
serializeHeader(DataOutputStream dos)
Serialize a trie2 Header and Index onto an OutputStream.
|
clone, getClass, notify, notifyAll, toString, wait, wait, waitforEach, spliteratorpublic static Trie2 createFromSerialized(ByteBuffer bytes) throws IOException
bytes - a byte buffer to the serialized form of a UTrie2.IllegalArgumentException - if the stream does not contain a serialized Trie2.IOException - if a read error occurs in the buffer.public static int getVersion(InputStream is, boolean littleEndianOk) throws IOException
is - an InputStream containing the serialized form
of a UTrie, version 1 or 2. The stream must support mark() and reset().
The position of the input stream will be left unchanged.littleEndianOk - If false, only big-endian (Java native) serialized forms are recognized.
If true, little-endian serialized forms are recognized as well.IOException - on errors in reading from the input stream.public abstract int get(int codePoint)
codePoint - the code pointpublic abstract int getFromU16SingleLead(char c)
c - the code point or lead surrogate value.public final boolean equals(Object other)
public Iterator<Trie2.Range> iterator()
iterator in interface Iterable<Trie2.Range>public Iterator<Trie2.Range> iterator(Trie2.ValueMapper mapper)
mapper - provides a function to remap values obtained from the Trie2.public Iterator<Trie2.Range> iteratorForLeadSurrogate(char lead, Trie2.ValueMapper mapper)
public Iterator<Trie2.Range> iteratorForLeadSurrogate(char lead)
protected int serializeHeader(DataOutputStream dos) throws IOException
dos - the stream to which the serialized Trie2 data will be written.IOExceptionpublic Trie2.CharSequenceIterator charSequenceIterator(CharSequence text, int index)
text - A text string to be iterated over.index - The starting iteration position within the input text.