Class FieldComparatorBase

  • Direct Known Subclasses:
    AbstractFieldComparator

    public abstract class FieldComparatorBase
    extends FieldComparator
    Abstract base class for FieldComparator implementations which are based on values in the form of Comparables.
    • Constructor Detail

      • FieldComparatorBase

        public FieldComparatorBase()
    • Method Detail

      • sortValue

        protected abstract Comparable<?> sortValue​(int doc)
        Value for a document
        Parameters:
        doc - id of the document
        Returns:
        the value for the given id
      • getValue

        protected abstract Comparable<?> getValue​(int slot)
        Retrieves the value of a given slot
        Parameters:
        slot - index of the value to retrieve
        Returns:
        the value in the given slot
      • setValue

        protected abstract void setValue​(int slot,
                                         Comparable<?> value)
        Puts a value into a given slot
        Parameters:
        slot - index where to put the value
        value - the value to put into the given slot
      • compare

        protected int compare​(Comparable<?> val1,
                              Comparable<?> val2)
        Compare two values
        Parameters:
        val1 - first value
        val2 - second value
        Returns:
        A negative integer if val1 comes before val2, a positive integer if val1 comes after val2 and 0 if val1 and val2 are equal.