Package com.ibm.icu.impl
Class Trie2_16
java.lang.Object
com.ibm.icu.impl.Trie2
com.ibm.icu.impl.Trie2_16
- All Implemented Interfaces:
Iterable<Trie2.Range>
-
Nested Class Summary
Nested classes/interfaces inherited from class com.ibm.icu.impl.Trie2
Trie2.CharSequenceIterator, Trie2.CharSequenceValues, Trie2.Range, Trie2.Trie2Iterator, Trie2.UTrie2Header, Trie2.ValueMapper, Trie2.ValueWidth
-
Field Summary
Fields inherited from class com.ibm.icu.impl.Trie2
data16, data32, dataLength, dataNullOffset, errorValue, fHash, header, highStart, highValueIndex, index, index2NullOffset, indexLength, initialValue, UNEWTRIE2_INDEX_1_LENGTH, UNEWTRIE2_INDEX_GAP_LENGTH, UNEWTRIE2_INDEX_GAP_OFFSET, UNEWTRIE2_MAX_DATA_LENGTH, UNEWTRIE2_MAX_INDEX_2_LENGTH, UTRIE2_BAD_UTF8_DATA_OFFSET, UTRIE2_CP_PER_INDEX_1_ENTRY, UTRIE2_DATA_BLOCK_LENGTH, UTRIE2_DATA_GRANULARITY, UTRIE2_DATA_MASK, UTRIE2_DATA_START_OFFSET, UTRIE2_INDEX_1_OFFSET, UTRIE2_INDEX_2_BLOCK_LENGTH, UTRIE2_INDEX_2_BMP_LENGTH, UTRIE2_INDEX_2_MASK, UTRIE2_INDEX_2_OFFSET, UTRIE2_INDEX_SHIFT, UTRIE2_LSCP_INDEX_2_LENGTH, UTRIE2_LSCP_INDEX_2_OFFSET, UTRIE2_MAX_INDEX_1_LENGTH, UTRIE2_OMITTED_BMP_INDEX_1_LENGTH, UTRIE2_OPTIONS_VALUE_BITS_MASK, UTRIE2_SHIFT_1, UTRIE2_SHIFT_1_2, UTRIE2_SHIFT_2, UTRIE2_UTF8_2B_INDEX_2_LENGTH, UTRIE2_UTF8_2B_INDEX_2_OFFSET
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Trie2_16
createFromSerialized
(ByteBuffer bytes) Create a Trie2 from its serialized form.final int
get
(int codePoint) Get the value for a code point as stored in the Trie2.int
getFromU16SingleLead
(char codeUnit) Get a Trie2 value for a UTF-16 code unit.int
(package private) int
rangeEnd
(int startingCP, int limit, int value) Given a starting code point, find the last in a range of code points, all with the same value.int
Serialize a Trie2_16 onto an OutputStream.Methods inherited from class com.ibm.icu.impl.Trie2
charSequenceIterator, equals, getVersion, hashCode, iterator, iterator, iteratorForLeadSurrogate, iteratorForLeadSurrogate, serializeHeader
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
Trie2_16
Trie2_16()Internal constructor, not for general use.
-
-
Method Details
-
createFromSerialized
Create a Trie2 from its serialized form. Inverse of utrie2_serialize(). The serialized format is identical between ICU4C and ICU4J, so this function will work with serialized Trie2s from either. The serialized Trie2 in the bytes may be in either little or big endian byte order. This allows using serialized Tries from ICU4C without needing to consider the byte order of the system that created them.- Parameters:
bytes
- a byte buffer to the serialized form of a UTrie2.- Returns:
- An unserialized Trie2_16, ready for use.
- Throws:
IllegalArgumentException
- if the buffer does not contain a serialized Trie2.IOException
- if a read error occurs in the buffer.ClassCastException
- if the bytes contain a serialized Trie2_32
-
get
public final int get(int codePoint) Get the value for a code point as stored in the Trie2. -
getFromU16SingleLead
public int getFromU16SingleLead(char codeUnit) Get a Trie2 value for a UTF-16 code unit. This function returns the same value as get() if the input character is outside of the lead surrogate range There are two values stored in a Trie2 for inputs in the lead surrogate range. This function returns the alternate value, while Trie2.get() returns the main value.- Specified by:
getFromU16SingleLead
in classTrie2
- Parameters:
codeUnit
- a 16 bit code unit or lead surrogate value.- Returns:
- the value
-
serialize
Serialize a Trie2_16 onto an OutputStream. A Trie2 can be serialized multiple times. The serialized data is compatible with ICU4C UTrie2 serialization. Trie2 serialization is unrelated to Java object serialization.- Parameters:
os
- the stream to which the serialized Trie2 data will be written.- Returns:
- the number of bytes written.
- Throws:
IOException
-
getSerializedLength
public int getSerializedLength()- Returns:
- the number of bytes of the serialized trie
-
rangeEnd
int rangeEnd(int startingCP, int limit, int value) Given a starting code point, find the last in a range of code points, all with the same value. This function is part of the implementation of iterating over the Trie2's contents.
-