Class CharTrie


  • public class CharTrie
    extends Trie
    Trie implementation which stores data in char, 16 bits.
    Since:
    release 2.1, Jan 01 2002
    See Also:
    Trie
    • Constructor Summary

      Constructors 
      Constructor Description
      CharTrie​(int initialValue, int leadUnitValue, Trie.DataManipulate dataManipulate)
      Make a dummy CharTrie.
      CharTrie​(java.io.InputStream inputStream, Trie.DataManipulate dataManipulate)
      Creates a new Trie with the settings for the trie data.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean equals​(java.lang.Object other)
      Checks if the argument Trie has the same data as this Trie
      char getBMPValue​(char ch)
      Get the value associated with the BMP code point.
      char getCodePointValue​(int ch)
      Gets the value associated with the codepoint.
      char getLatin1LinearValue​(char ch)
      Gets the latin 1 fast path value.
      char getLeadValue​(char ch)
      Gets the value to the data which this lead surrogate character points to.
      char getSurrogateValue​(char lead, char trail)
      Get the value associated with a pair of surrogates.
      char getTrailValue​(int leadvalue, char trail)
      Get a value from a folding offset (from the value of a lead surrogate) and a trail surrogate.
      void putIndexData​(UCharacterProperty friend)
      Java friend implementation To store the index and data array into the argument.
      • Methods inherited from class java.lang.Object

        getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CharTrie

        public CharTrie​(java.io.InputStream inputStream,
                        Trie.DataManipulate dataManipulate)
                 throws java.io.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:
        inputStream - file input stream to a ICU data file, containing the trie
        dataManipulate - object which provides methods to parse the char data
        Throws:
        java.io.IOException - thrown when data reading fails
      • CharTrie

        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 - the initial value that is set for all code points
        leadUnitValue - the value for lead surrogate code _units_ that do not have associated supplementary data
        dataManipulate - object which provides methods to parse the char data
    • Method Detail

      • putIndexData

        public void putIndexData​(UCharacterProperty friend)
        Java friend implementation To store the index and data array into the argument.
        Parameters:
        friend - java friend UCharacterProperty object to store the array
      • getCodePointValue

        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 - codepoint
        Returns:
        offset to data
      • getLeadValue

        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 - lead surrogate character
        Returns:
        data value
      • getBMPValue

        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 - the input BMP code point
        Returns:
        trie data value associated with the BMP codepoint
      • getSurrogateValue

        public final char getSurrogateValue​(char lead,
                                            char trail)
        Get the value associated with a pair of surrogates.
        Parameters:
        lead - a lead surrogate
        trail - a trail surrogate
      • getTrailValue

        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 - value associated with the lead surrogate which contains the folding offset
        trail - surrogate
        Returns:
        trie data value associated with the trail character
      • getLatin1LinearValue

        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 - latin 1 characters
        Returns:
        value associated with latin character
      • equals

        public boolean equals​(java.lang.Object other)
        Checks if the argument Trie has the same data as this Trie
        Overrides:
        equals in class Trie
        Parameters:
        other - Trie to check
        Returns:
        true if the argument Trie has the same data as this Trie, false otherwise