Package com.ibm.icu.impl
Class IntTrie
java.lang.Object
com.ibm.icu.impl.Trie
com.ibm.icu.impl.IntTrie
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.- Since:
- release 2.1, Jan 01 2002
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class com.ibm.icu.impl.Trie
Trie.DataManipulate
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int[]
Array of char dataprivate int
Default valueFields inherited from class com.ibm.icu.impl.Trie
BMP_INDEX_LENGTH, DATA_BLOCK_LENGTH, HEADER_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_BITS, SURROGATE_BLOCK_COUNT, SURROGATE_MASK_
-
Constructor Summary
ConstructorsConstructorDescriptionIntTrie
(char[] index, int[] data, int initialvalue, int options, Trie.DataManipulate datamanipulate) Internal constructor for builder useIntTrie
(int initialValue, int leadUnitValue, Trie.DataManipulate dataManipulate) Make a dummy IntTrie.IntTrie
(ByteBuffer bytes, Trie.DataManipulate dataManipulate) Creates a new Trie with the settings for the trie data. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks if the argument Trie has the same data as this Triefinal int
getBMPValue
(char ch) Get the value associated with the BMP code point.final int
getCodePointValue
(int ch) Gets the value associated with the codepoint.protected final int
Gets the default initial valuefinal int
getLatin1LinearValue
(char ch) Gets the latin 1 fast path value.final int
getLeadValue
(char ch) Gets the value to the data which this lead surrogate character points to.protected final int
getSurrogateOffset
(char lead, char trail) Gets the offset to the data which the surrogate pair points to.final int
getSurrogateValue
(char lead, char trail) Get the value associated with a pair of surrogates.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.protected final int
getValue
(int index) Gets the value at the argument index.int
hashCode()
protected final void
unserialize
(ByteBuffer bytes) Parses the input stream and stores its trie content into a index and data arrayMethods inherited from class com.ibm.icu.impl.Trie
getBMPOffset, getCodePointOffset, getLeadOffset, getRawOffset, getSerializedDataSize, isCharTrie, isIntTrie, isLatin1Linear
-
Field Details
-
m_initialValue_
private int m_initialValue_Default value -
m_data_
private int[] m_data_Array of char data
-
-
Constructor Details
-
IntTrie
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
- file buffer to a ICU data file, containing the triedataManipulate
- object which provides methods to parse the char data- Throws:
IOException
- thrown when data reading fails
-
IntTrie
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
- the initial value that is set for all code pointsleadUnitValue
- the value for lead surrogate code _units_ that do not have associated supplementary datadataManipulate
- object which provides methods to parse the char data
-
IntTrie
IntTrie(char[] index, int[] data, int initialvalue, int options, Trie.DataManipulate datamanipulate) Internal constructor for builder use- Parameters:
index
- the index array to be slotted into this triedata
- the data array to be slotted into this trieinitialvalue
- the initial value for this trieoptions
- trie options to usedatamanipulate
- folding implementation
-
-
Method Details
-
getCodePointValue
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
- codepoint- Returns:
- offset to data
-
getLeadValue
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
- lead surrogate character- Returns:
- data value
-
getBMPValue
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
- the input BMP code point- Returns:
- trie data value associated with the BMP codepoint
-
getSurrogateValue
public final int getSurrogateValue(char lead, char trail) Get the value associated with a pair of surrogates.- Parameters:
lead
- a lead surrogatetrail
- a trail surrogate
-
getTrailValue
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
- the value of a lead surrogate that contains the folding offsettrail
- surrogate- Returns:
- trie data value associated with the trail character
-
getLatin1LinearValue
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
- latin 1 characters- Returns:
- value associated with latin character
-
equals
Checks if the argument Trie has the same data as this Trie -
hashCode
public int hashCode() -
unserialize
Parses the input stream and stores its trie content into a index and data array
- Overrides:
unserialize
in classTrie
- Parameters:
bytes
- data buffer containing trie data
-
getSurrogateOffset
protected final int getSurrogateOffset(char lead, char trail) Gets the offset to the data which the surrogate pair points to.- Specified by:
getSurrogateOffset
in classTrie
- Parameters:
lead
- lead surrogatetrail
- trailing surrogate- Returns:
- offset to data
-
getValue
protected final int getValue(int index) Gets the value at the argument index. For use internally in TrieIterator -
getInitialValue
protected final int getInitialValue()Gets the default initial value- Specified by:
getInitialValue
in classTrie
- Returns:
- 32 bit value
-