Class TextComparer

  • All Implemented Interfaces:
    java.io.Serializable, java.util.Comparator

    public class TextComparer
    extends java.lang.Object
    implements java.util.Comparator, java.io.Serializable
    A Comparer used for comparing sort keys when data-type="text". The items to be compared are converted to strings, and the strings are then compared using an underlying collator
    Author:
    Michael H. Kay
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      TextComparer​(java.util.Comparator collator)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int compare​(java.lang.Object a, java.lang.Object b)
      Compare two Items by converting them to strings and comparing the string values.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.util.Comparator

        equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
    • Constructor Detail

      • TextComparer

        public TextComparer​(java.util.Comparator collator)
    • Method Detail

      • compare

        public int compare​(java.lang.Object a,
                           java.lang.Object b)
                    throws java.lang.ClassCastException
        Compare two Items by converting them to strings and comparing the string values.
        Specified by:
        compare in interface java.util.Comparator
        Parameters:
        a - the first Item to be compared.
        b - the second Item to be compared.
        Returns:
        <0 if a0 if a>b
        Throws:
        java.lang.ClassCastException - if the objects are not Items, or are items that cannot be convered to strings (e.g. QNames)