Class UppercaseFirstCollator

  • All Implemented Interfaces:
    java.io.Serializable, StringCollator

    public class UppercaseFirstCollator
    extends java.lang.Object
    implements StringCollator, java.io.Serializable
    A Collator used for comparing strings, with upper case collated before lower case if the strings are otherwise equal. This is implemented as a wrapper around a collator that compares the strings ignoring case.
    Author:
    Michael H. Kay
    See Also:
    Serialized Form
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compareStrings​(java.lang.String a, java.lang.String b)
      Compare two string objects: case is irrelevant, unless the strings are equal ignoring case, in which case uppercase comes first.
      java.lang.Object getCollationKey​(java.lang.String s)
      Get a collation key for two Strings.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • UppercaseFirstCollator

        public UppercaseFirstCollator​(StringCollator base)
        Create an UppercaseFirstCollator
        Parameters:
        base - the base collator used to compare strings irrespective of case
    • Method Detail

      • compareStrings

        public int compareStrings​(java.lang.String a,
                                  java.lang.String b)
        Compare two string objects: case is irrelevant, unless the strings are equal ignoring case, in which case uppercase comes first.
        Specified by:
        compareStrings in interface StringCollator
        Parameters:
        a - the first string
        b - the second string
        Returns:
        <0 if a0 if a>b
        Throws:
        java.lang.ClassCastException - if the objects do not implement the CharSequence interface
      • getCollationKey

        public java.lang.Object getCollationKey​(java.lang.String s)
        Get a collation key for two Strings. The essential property of collation keys is that if two values are equal under the collation, then the collation keys are compare correctly under the equals() method.
        Specified by:
        getCollationKey in interface StringCollator
        Parameters:
        s - the string whose collation key is required
        Returns:
        the collation key