Class Latin1

All Implemented Interfaces:
Comparable<UnicodeString>, AtomicMatchKey

public class Latin1 extends Twine8
An implementation of UnicodeString that subclasses Twine8 (so it is only suitable for codepoints up to 255), and that also caches a String representing the same characters. This is wasteful of space, so it is used predominantly for static constants.
  • Constructor Details

    • Latin1

      protected Latin1(String baseString)
      Protected constructor
      Parameters:
      baseString - the string to be wrapped: the caller is responsible for ensuring this contains no codepoints above 255
  • Method Details

    • of

      public static Latin1 of(String base)
      Wrap a String, which must contain no surrogates
      Parameters:
      base - the string. The caller warrants that this string contains no surrogates; this condition is checked only if Java assertions are enabled.
      Returns:
      the wrapped string.
    • compareTo

      public int compareTo(UnicodeString other)
      Description copied from class: UnicodeString
      Compare this string to another using codepoint comparison
      Specified by:
      compareTo in interface Comparable<UnicodeString>
      Overrides:
      compareTo in class Twine8
      Parameters:
      other - the other string
      Returns:
      -1 if this string comes first, 0 if they are equal, +1 if the other string comes first
    • equals

      public boolean equals(Object obj)
      Description copied from class: Twine8
      Test whether this StringValue is equal to another under the rules of the codepoint collation. The type annotation is ignored.
      Overrides:
      equals in class Twine8
      Parameters:
      obj - the value to be compared with this value
      Returns:
      true if the strings are equal on a codepoint-by-codepoint basis
    • toString

      public String toString()
      Description copied from class: Twine8
      Display as a string.
      Overrides:
      toString in class Twine8