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

public Class IntTrie

extends Trie
Class Inheritance
Imports
java.io.IOException, java.nio.ByteBuffer, java.util.Arrays, com.ibm.icu.text.UTF16

Trie implementation which stores data in int, 32 bits. 2015-sep-03: Used only in CharsetSelector which could be switched to Trie2_32 as long as that does not load ICU4C selector data.
Author
synwee
Since
release 2.1, Jan 01 2002
See Also
com.ibm.icu.impl.Trie

Field Summary

Modifier and TypeField and Description
private int[]
m_data_

Array of char data

private int
m_initialValue_

Default value

Inherited from com.ibm.icu.impl.Trie:
BMP_INDEX_LENGTHDATA_BLOCK_LENGTHHEADER_LENGTH_HEADER_OPTIONS_DATA_IS_32_BIT_HEADER_OPTIONS_INDEX_SHIFT_HEADER_OPTIONS_LATIN1_IS_LINEAR_MASK_HEADER_SIGNATURE_INDEX_STAGE_1_SHIFT_INDEX_STAGE_2_SHIFT_INDEX_STAGE_3_MASK_LEAD_INDEX_OFFSET_m_dataLength_m_dataManipulate_m_dataOffset_m_index_SURROGATE_BLOCK_BITSSURROGATE_BLOCK_COUNTSURROGATE_MASK_

Constructor Summary

AccessConstructor and Description
public
IntTrie(ByteBuffer
file buffer to a ICU data file, containing the trie
bytes
,
Trie.DataManipulate
object which provides methods to parse the char data
dataManipulate
)

Creates a new Trie with the settings for the trie data.

public
IntTrie(int
the initial value that is set for all code points
initialValue
,
int
the value for lead surrogate code _units_ that do not have associated supplementary data
leadUnitValue
,
Trie.DataManipulate
object which provides methods to parse the char data
dataManipulate
)

Make a dummy IntTrie.

pack-priv
IntTrie(char[]
the index array to be slotted into this trie
index
,
int[]
the data array to be slotted into this trie
data
,
int
the initial value for this trie
initialvalue
,
int
trie options to use
options
,
Trie.DataManipulate
folding implementation
datamanipulate
)

Internal constructor for builder use

Method Summary

Modifier and TypeMethod and Description
public boolean

Returns:

true if the argument Trie has the same data as this Trie, false otherwise
equals
(Object
Trie to check
other
)

Overrides com.ibm.icu.impl.Trie.equals.

Checks if the argument Trie has the same data as this Trie
public final int

Returns:

trie data value associated with the BMP codepoint
getBMPValue
(char
the input BMP code point
ch
)

Get the value associated with the BMP code point.

public final int

Returns:

offset to data
getCodePointValue
(int
codepoint
ch
)

Gets the value associated with the codepoint.

protected final int

Returns:

32 bit value
getInitialValue
()

Implements abstract com.ibm.icu.impl.Trie.getInitialValue.

Gets the default initial value
public final int

Returns:

value associated with latin character
getLatin1LinearValue
(char
latin 1 characters
ch
)

Gets the latin 1 fast path value.

public final int

Returns:

data value
getLeadValue
(char
lead surrogate character
ch
)

Gets the value to the data which this lead surrogate character points to.

protected final int

Returns:

offset to data
getSurrogateOffset
(char
lead surrogate
lead
,
char
trailing surrogate
trail
)

Implements abstract com.ibm.icu.impl.Trie.getSurrogateOffset.

Gets the offset to the data which the surrogate pair points to.
public final int
getSurrogateValue(char
a lead surrogate
lead
,
char
a trail surrogate
trail
)

Get the value associated with a pair of surrogates.

public final int

Returns:

trie data value associated with the trail character
getTrailValue
(int
the value of a lead surrogate that contains the folding offset
leadvalue
,
char
surrogate
trail
)

Get a value from a folding offset (from the value of a lead surrogate) and a trail surrogate.

protected final int

Returns:

32 bit value
getValue
(int
value at index will be retrieved
index
)

Implements abstract com.ibm.icu.impl.Trie.getValue.

Gets the value at the argument index.
public int
hashCode()

Overrides com.ibm.icu.impl.Trie.hashCode.

Returns a hash code value for the object.
protected final void
unserialize(ByteBuffer
data buffer containing trie data
bytes
)

Overrides com.ibm.icu.impl.Trie.unserialize.

Parses the input stream and stores its trie content into a index and data array

Inherited from com.ibm.icu.impl.Trie:
getBMPOffsetgetCodePointOffsetgetLeadOffsetgetRawOffsetgetSerializedDataSizeisCharTrieisIntTrieisLatin1Linear

Field Detail

m_data_back to summary
private int[] m_data_

Array of char data

m_initialValue_back to summary
private int m_initialValue_

Default value

Constructor Detail

IntTrieback to summary
public IntTrie(ByteBuffer bytes, Trie.DataManipulate dataManipulate) throws IOException

Creates a new Trie with the settings for the trie data.

Unserialize the 32-bit-aligned input stream and use the data for the trie.

Parameters
bytes:ByteBuffer

file buffer to a ICU data file, containing the trie

dataManipulate:Trie.DataManipulate

object which provides methods to parse the char data

Exceptions
IOException:
thrown when data reading fails
IntTrieback to summary
public IntTrie(int initialValue, int leadUnitValue, Trie.DataManipulate dataManipulate)

Make a dummy IntTrie. A dummy trie is an empty runtime trie, used when a real data trie cannot be loaded. The trie always returns the initialValue, or the leadUnitValue for lead surrogate code points. The Latin-1 part is always set up to be linear.

Parameters
initialValue:int

the initial value that is set for all code points

leadUnitValue:int

the value for lead surrogate code _units_ that do not have associated supplementary data

dataManipulate:Trie.DataManipulate

object which provides methods to parse the char data

Annotations
@SuppressWarnings:all
IntTrieback to summary
pack-priv IntTrie(char[] index, int[] data, int initialvalue, int options, Trie.DataManipulate datamanipulate)

Internal constructor for builder use

Parameters
index:char[]

the index array to be slotted into this trie

data:int[]

the data array to be slotted into this trie

initialvalue:int

the initial value for this trie

options:int

trie options to use

datamanipulate:Trie.DataManipulate

folding implementation

Method Detail

equalsback to summary
public boolean equals(Object other)

Overrides com.ibm.icu.impl.Trie.equals.

Checks if the argument Trie has the same data as this Trie

Parameters
other:Object

Trie to check

Returns:boolean

true if the argument Trie has the same data as this Trie, false otherwise

Annotations
@Override
getBMPValueback to summary
public final int getBMPValue(char ch)

Get the value associated with the BMP code point. Lead surrogate code points are treated as normal code points, with unfolded values that may differ from getLeadValue() results.

Parameters
ch:char

the input BMP code point

Returns:int

trie data value associated with the BMP codepoint

getCodePointValueback to summary
public final int getCodePointValue(int ch)

Gets the value associated with the codepoint. If no value is associated with the codepoint, a default value will be returned.

Parameters
ch:int

codepoint

Returns:int

offset to data

getInitialValueback to summary
protected final int getInitialValue()

Implements abstract com.ibm.icu.impl.Trie.getInitialValue.

Gets the default initial value

Returns:int

32 bit value

Annotations
@Override
getLatin1LinearValueback to summary
public final int getLatin1LinearValue(char ch)

Gets the latin 1 fast path value.

Note this only works if latin 1 characters have their own linear array.

Parameters
ch:char

latin 1 characters

Returns:int

value associated with latin character

getLeadValueback to summary
public final int getLeadValue(char ch)

Gets the value to the data which this lead surrogate character points to. Returned data may contain folding offset information for the next trailing surrogate character. This method does not guarantee correct results for trail surrogates.

Parameters
ch:char

lead surrogate character

Returns:int

data value

getSurrogateOffsetback to summary
protected final int getSurrogateOffset(char lead, char trail)

Implements abstract com.ibm.icu.impl.Trie.getSurrogateOffset.

Gets the offset to the data which the surrogate pair points to.

Parameters
lead:char

lead surrogate

trail:char

trailing surrogate

Returns:int

offset to data

Annotations
@Override
getSurrogateValueback to summary
public final int getSurrogateValue(char lead, char trail)

Get the value associated with a pair of surrogates.

Parameters
lead:char

a lead surrogate

trail:char

a trail surrogate

getTrailValueback to summary
public final int getTrailValue(int leadvalue, char trail)

Get a value from a folding offset (from the value of a lead surrogate) and a trail surrogate.

Parameters
leadvalue:int

the value of a lead surrogate that contains the folding offset

trail:char

surrogate

Returns:int

trie data value associated with the trail character

getValueback to summary
protected final int getValue(int index)

Implements abstract com.ibm.icu.impl.Trie.getValue.

Gets the value at the argument index. For use internally in TrieIterator

Parameters
index:int

value at index will be retrieved

Returns:int

32 bit value

Annotations
@Override
See Also
com.ibm.icu.impl.TrieIterator
hashCodeback to summary
public int hashCode()

Overrides com.ibm.icu.impl.Trie.hashCode.

Doc from java.lang.Object.hashCode.

Returns a hash code value for the object. This method is supported for the benefit of hash tables such as those provided by java.util.HashMap.

The general contract of hashCode is:

  • Whenever it is invoked on the same object more than once during an execution of a Java application, the hashCode method must consistently return the same integer, provided no information used in equals comparisons on the object is modified. This integer need not remain consistent from one execution of an application to another execution of the same application.
  • If two objects are equal according to the equals method, then calling the hashCode method on each of the two objects must produce the same integer result.
  • It is not required that if two objects are unequal according to the equals method, then calling the hashCode method on each of the two objects must produce distinct integer results. However, the programmer should be aware that producing distinct integer results for unequal objects may improve the performance of hash tables.
Returns:int

a hash code value for this object.

Annotations
@Override
unserializeback to summary
protected final void unserialize(ByteBuffer bytes)

Overrides com.ibm.icu.impl.Trie.unserialize.

Parses the input stream and stores its trie content into a index and data array

Parameters
bytes:ByteBuffer

data buffer containing trie data

Annotations
@Override