Top Description Inners Fields Constructors Methods
com.ibm.icu.impl

public abstract Class Trie2

extends Object
implements Iterable<Trie2.Range>
Class Inheritance
All Implemented Interfaces
java.lang.Iterable
Known Direct Subclasses
com.ibm.icu.impl.Trie2Writable, com.ibm.icu.impl.Trie2_16, com.ibm.icu.impl.Trie2_32
Imports
java.io.DataOutputStream, .IOException, .InputStream, java.nio.ByteBuffer, .ByteOrder, java.util.Iterator, .NoSuchElementException

This is the interface and common implementation of a Unicode Trie2. It is a kind of compressed table that maps from Unicode code points (0..0x10ffff) to 16- or 32-bit integer values. It works best when there are ranges of characters with the same value, which is generally the case with Unicode character properties. This is the second common version of a Unicode trie (hence the name Trie2).

Nested and Inner Type Summary

Modifier and TypeClass and Description
public 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.

public static class
Trie2.CharSequenceValues

Struct-like class for holding the results returned by a UTrie2 CharSequence iterator.

public static class
Trie2.Range

When iterating over the contents of a Trie2, Elements of this type are produced.

pack-priv class
Trie2.Trie2Iterator

Implementation class for an iterator over a Trie2.

pack-priv static class
Trie2.UTrie2Header

Trie2 data structure in serialized form: UTrie2Header header; uint16_t index[header.index2Length]; uint16_t data[header.shiftedDataLength<<2]; -- or uint32_t data[...] For Java, this is read from the stream into an instance of UTrie2Header.

public 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.

pack-priv static enum
Trie2.ValueWidth

Selectors for the width of a UTrie2 data value.

Field Summary

Modifier and TypeField and Description
pack-priv int
pack-priv int[]
pack-priv int
pack-priv int
private static Trie2.ValueMapper
pack-priv int
errorValue

Value returned for out-of-range code points and illegal UTF-8.

pack-priv int
pack-priv Trie2.UTrie2Header
pack-priv int
pack-priv int
pack-priv char[]
pack-priv int
pack-priv int
pack-priv int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
UNEWTRIE2_MAX_DATA_LENGTH

Maximum length of the build-time data array.

pack-priv static final int
UNEWTRIE2_MAX_INDEX_2_LENGTH

Maximum length of the build-time index-2 array.

pack-priv static final int
UTRIE2_BAD_UTF8_DATA_OFFSET

The illegal-UTF-8 data block follows the ASCII block, at offset 128=0x80.

pack-priv static final int
UTRIE2_CP_PER_INDEX_1_ENTRY

Number of code points per index-1 table entry.

pack-priv static final int
UTRIE2_DATA_BLOCK_LENGTH

Number of entries in a data block.

pack-priv static final int
UTRIE2_DATA_GRANULARITY

The alignment size of a data block.

pack-priv static final int
UTRIE2_DATA_MASK

Mask for getting the lower bits for the in-data-block offset.

pack-priv static final int
UTRIE2_DATA_START_OFFSET

The start of non-linear-ASCII data blocks, at offset 192=0xc0.

pack-priv static final int
UTRIE2_INDEX_1_OFFSET

The index-1 table, only used for supplementary code points, at offset 2112=0x840.

pack-priv static final int
UTRIE2_INDEX_2_BLOCK_LENGTH

Number of entries in an index-2 block.

pack-priv static final int
UTRIE2_INDEX_2_BMP_LENGTH

Count the lengths of both BMP pieces.

pack-priv static final int
UTRIE2_INDEX_2_MASK

Mask for getting the lower bits for the in-index-2-block offset.

pack-priv static final int
UTRIE2_INDEX_2_OFFSET

The BMP part of the index-2 table is fixed and linear and starts at offset 0.

pack-priv static final int
UTRIE2_INDEX_SHIFT

Shift size for shifting left the index array values.

pack-priv static final int
pack-priv static final int
UTRIE2_LSCP_INDEX_2_OFFSET

The part of the index-2 table for U+D800..U+DBFF stores values for lead surrogate code _units_ not code _points_.

pack-priv static final int
pack-priv static final int
UTRIE2_OMITTED_BMP_INDEX_1_LENGTH

Number of index-1 entries for the BMP.

pack-priv static final int
UTRIE2_OPTIONS_VALUE_BITS_MASK

Trie2 constants, defining shift widths, index array lengths, etc. These are needed for the runtime macros but users can treat these as implementation details and skip to the actual public API further below.

pack-priv static final int
UTRIE2_SHIFT_1

Shift size for getting the index-1 table offset.

pack-priv static final int
UTRIE2_SHIFT_1_2

Difference between the two shift sizes, for getting an index-1 offset from an index-2 offset.

pack-priv static final int
UTRIE2_SHIFT_2

Shift size for getting the index-2 table offset.

pack-priv static final int
pack-priv static final int
UTRIE2_UTF8_2B_INDEX_2_OFFSET

The 2-byte UTF-8 version of the index-2 table follows at offset 2080=0x820.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public Trie2.CharSequenceIterator

Returns:

the CharSequenceIterator
charSequenceIterator
(CharSequence
A text string to be iterated over.
text
,
int
The starting iteration position within the input text.
index
)

Create an iterator that will produce the values from the Trie2 for the sequence of code points in an input text.

public static Trie2

Returns:

An unserialized Trie2, ready for use.
createFromSerialized
(ByteBuffer
a byte buffer to the serialized form of a UTrie2.
bytes
)

Create a Trie2 from its serialized form.

public final boolean
equals(Object
the reference object with which to compare.
other
)

Overrides java.lang.Object.equals.

Equals function.
public abstract int

Returns:

the value
get
(int
the code point
codePoint
)

Get the value for a code point as stored in the Trie2.

public abstract int

Returns:

the value
getFromU16SingleLead
(char
the code point or lead surrogate value.
c
)

Get the trie value for a UTF-16 code unit.

public static int

Returns:

the Trie version of the serialized form, or 0 if it is not recognized as a serialized UTrie
getVersion
(InputStream
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.
is
,
boolean
If false, only big-endian (Java native) serialized forms are recognized. If true, little-endian serialized forms are recognized as well.
littleEndianOk
)

Get the UTrie version from an InputStream containing the serialized form of either a Trie (version 1) or a Trie2 (version 2).

private static int
hashByte(int h, int b)

public int
hashCode()

Overrides java.lang.Object.hashCode.

Returns a hash code value for the object.
private static int
hashInt(int h, int i)

private static int
hashUChar32(int h, int c)

private static int
public Iterator<Trie2.Range>

Returns:

an Iterator
iterator
()

Implements java.lang.Iterable.iterator.

Create an iterator over the value ranges in this Trie2.
public Iterator<Trie2.Range>

Returns:

an Iterator
iterator
(Trie2.ValueMapper
provides a function to remap values obtained from the Trie2.
mapper
)

Create an iterator over the value ranges from this Trie2.

public 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.

public 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.

pack-priv int

Returns:

The last contiguous character with the same value.
rangeEnd
(int
The character to begin with.
start
,
int limitp, int val)

Find the last character in a contiguous range of characters with the same Trie2 value as the input character.

protected int

Returns:

the number of bytes written.
serializeHeader
(DataOutputStream
the stream to which the serialized Trie2 data will be written.
dos
)

Serialize a trie2 Header and Index onto an OutputStream.

Inherited from java.lang.Object:
clonefinalizegetClassnotifynotifyAlltoStringwaitwaitwait