Class Trie2_32

  • All Implemented Interfaces:
    java.lang.Iterable<Trie2.Range>

    public class Trie2_32
    extends Trie2
    • Constructor Detail

      • Trie2_32

        Trie2_32()
        Internal constructor, not for general use.
    • Method Detail

      • createFromSerialized

        public static Trie2_32 createFromSerialized​(java.nio.ByteBuffer bytes)
                                             throws java.io.IOException
        Create a Trie2 from its serialized form. Inverse of utrie2_serialize(). The serialized format is identical between ICU4C and ICU4J, so this function will work with serialized Trie2s from either. The serialized Trie2 in the bytes may be in either little or big endian byte order. This allows using serialized Tries from ICU4C without needing to consider the byte order of the system that created them.
        Parameters:
        bytes - a byte buffer to the serialized form of a UTrie2.
        Returns:
        An unserialized Trie_32, ready for use.
        Throws:
        java.lang.IllegalArgumentException - if the stream does not contain a serialized Trie2.
        java.io.IOException - if a read error occurs in the buffer.
        java.lang.ClassCastException - if the bytes contains a serialized Trie2_16
      • get

        public final int get​(int codePoint)
        Get the value for a code point as stored in the Trie2.
        Specified by:
        get in class Trie2
        Parameters:
        codePoint - the code point
        Returns:
        the value
      • getFromU16SingleLead

        public int getFromU16SingleLead​(char codeUnit)
        Get a Trie2 value for a UTF-16 code unit. This function returns the same value as get() if the input character is outside of the lead surrogate range There are two values stored in a Trie2 for inputs in the lead surrogate range. This function returns the alternate value, while Trie2.get() returns the main value.
        Specified by:
        getFromU16SingleLead in class Trie2
        Parameters:
        codeUnit - a 16 bit code unit or lead surrogate value.
        Returns:
        the value
      • serialize

        public int serialize​(java.io.OutputStream os)
                      throws java.io.IOException
        Serialize a Trie2_32 onto an OutputStream. A Trie2 can be serialized multiple times. The serialized data is compatible with ICU4C UTrie2 serialization. Trie2 serialization is unrelated to Java object serialization.
        Parameters:
        os - the stream to which the serialized Trie2 data will be written.
        Returns:
        the number of bytes written.
        Throws:
        java.io.IOException
      • getSerializedLength

        public int getSerializedLength()
        Returns:
        the number of bytes of the serialized trie
      • rangeEnd

        int rangeEnd​(int startingCP,
                     int limit,
                     int value)
        Given a starting code point, find the last in a range of code points, all with the same value. This function is part of the implementation of iterating over the Trie2's contents.
        Overrides:
        rangeEnd in class Trie2
        Parameters:
        startingCP - The code point at which to begin looking.
        Returns:
        The last code point with the same value as the starting code point.