Class LatinString

  • All Implemented Interfaces:
    java.lang.CharSequence, java.lang.Comparable<UnicodeString>, AtomicMatchKey

    public final class LatinString
    extends UnicodeString
    An implementation of UnicodeString optimized for strings that contain no characters outside the Latin-1 range (i.e. no characters whose codepoints exceed 255).
    • Constructor Summary

      Constructors 
      Constructor Description
      LatinString​(java.lang.CharSequence src)
      Create a LatinString
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      char charAt​(int index)
      Returns the char value at the specified index.
      boolean isEnd​(int pos)
      Ask whether a given position is at (or beyond) the end of the string
      int length()
      Returns the length of this character sequence.
      java.lang.CharSequence subSequence​(int start, int end)
      Returns a new CharSequence that is a subsequence of this sequence.
      java.lang.String toString()  
      int uCharAt​(int pos)
      Get the character at a specified position
      int uIndexOf​(int search, int pos)
      Get the first match for a given character
      int uLength()
      Get the length of the string, in Unicode codepoints
      LatinString uSubstring​(int beginIndex, int endIndex)
      Get a substring of this string
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface java.lang.CharSequence

        chars, codePoints
    • Field Detail

      • SINGLE_SPACE

        public static final LatinString SINGLE_SPACE
    • Constructor Detail

      • LatinString

        public LatinString​(java.lang.CharSequence src)
        Create a LatinString
        Parameters:
        src - The string value. The caller must ensure that this contains no characters > 255
    • Method Detail

      • uSubstring

        public LatinString uSubstring​(int beginIndex,
                                      int endIndex)
        Description copied from class: UnicodeString
        Get a substring of this string
        Specified by:
        uSubstring in class UnicodeString
        Parameters:
        beginIndex - the index of the first character to be included (counting codepoints, not 16-bit characters)
        endIndex - the index of the first character to be NOT included (counting codepoints, not 16-bit characters)
        Returns:
        a substring
      • uCharAt

        public int uCharAt​(int pos)
        Description copied from class: UnicodeString
        Get the character at a specified position
        Specified by:
        uCharAt in class UnicodeString
        Parameters:
        pos - the index of the required character (counting codepoints, not 16-bit characters)
        Returns:
        a character (Unicode codepoint) at the specified position.
      • uIndexOf

        public int uIndexOf​(int search,
                            int pos)
        Description copied from class: UnicodeString
        Get the first match for a given character
        Specified by:
        uIndexOf in class UnicodeString
        Parameters:
        search - the character to look for
        pos - the first position to look
        Returns:
        the position of the first occurrence of the sought character, or -1 if not found
      • uLength

        public int uLength()
        Description copied from class: UnicodeString
        Get the length of the string, in Unicode codepoints
        Specified by:
        uLength in class UnicodeString
        Returns:
        the number of codepoints in the string
      • isEnd

        public boolean isEnd​(int pos)
        Description copied from class: UnicodeString
        Ask whether a given position is at (or beyond) the end of the string
        Specified by:
        isEnd in class UnicodeString
        Parameters:
        pos - the index of the required character (counting codepoints, not 16-bit characters)
        Returns:
        true iff if the specified index is after the end of the character stream
      • toString

        public java.lang.String toString()
        Specified by:
        toString in interface java.lang.CharSequence
        Overrides:
        toString in class java.lang.Object
      • length

        public int length()
        Returns the length of this character sequence. The length is the number of 16-bit chars in the sequence.
        Returns:
        the number of chars in this sequence
      • charAt

        public char charAt​(int index)
        Returns the char value at the specified index. An index ranges from zero to length() - 1. The first char value of the sequence is at index zero, the next at index one, and so on, as for array indexing.

        If the char value specified by the index is a surrogate, the surrogate value is returned.

        Parameters:
        index - the index of the char value to be returned
        Returns:
        the specified char value
        Throws:
        java.lang.IndexOutOfBoundsException - if the index argument is negative or not less than length()
      • subSequence

        public java.lang.CharSequence subSequence​(int start,
                                                  int end)
        Returns a new CharSequence that is a subsequence of this sequence. The subsequence starts with the char value at the specified index and ends with the char value at index end - 1. The length (in chars) of the returned sequence is end - start, so if start == end then an empty sequence is returned.
        Parameters:
        start - the start index, inclusive
        end - the end index, exclusive
        Returns:
        the specified subsequence
        Throws:
        java.lang.IndexOutOfBoundsException - if start or end are negative, if end is greater than length(), or if start is greater than end