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

public Class CharTrie

extends Trie
Class Inheritance
Imports
java.nio.ByteBuffer, com.ibm.icu.text.UTF16

Trie implementation which stores data in char, 16 bits.
Author
synwee
Since
release 2.1, Jan 01 2002
See Also
com.ibm.icu.impl.Trie

Field Summary

Modifier and TypeField and Description
private char[]
m_data_

Array of char data

private char
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
CharTrie(ByteBuffer
data of an 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
CharTrie(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 CharTrie.

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 char

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 char

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 char

Returns:

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

Gets the latin 1 fast path value.

public final char

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 char
getSurrogateValue(char
a lead surrogate
lead
,
char
a trail surrogate
trail
)

Get the value associated with a pair of surrogates.

public final char

Returns:

trie data value associated with the trail character
getTrailValue
(int
value associated with the lead surrogate which 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
buffer containing trie data
bytes
)

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

Parses the byte buffer 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 char[] m_data_

Array of char data

m_initialValue_back to summary
private char m_initialValue_

Default value

Constructor Detail

CharTrieback to summary
public CharTrie(ByteBuffer bytes, Trie.DataManipulate dataManipulate)

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

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

Parameters
bytes:ByteBuffer

data of an ICU data file, containing the trie

dataManipulate:Trie.DataManipulate

object which provides methods to parse the char data

CharTrieback to summary
public CharTrie(int initialValue, int leadUnitValue, Trie.DataManipulate dataManipulate)

Make a dummy CharTrie. 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

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 char 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:char

trie data value associated with the BMP codepoint

getCodePointValueback to summary
public final char 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:char

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 char 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:char

value associated with latin character

getLeadValueback to summary
public final char 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:char

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 char 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 char getTrailValue(int leadvalue, char trail)

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

If the

Parameters
leadvalue:int

value associated with the lead surrogate which contains the folding offset

trail:char

surrogate

Returns:char

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 byte buffer and stores its trie content into a index and data array

Parameters
bytes:ByteBuffer

buffer containing trie data

Annotations
@Override