Package adams.core.io

Class FileComparator

  • All Implemented Interfaces:
    Comparator<File>

    public class FileComparator
    extends Object
    implements Comparator<File>
    Comparator for files.
    Version:
    $Revision$
    Author:
    fracpete (fracpete at waikato dot ac dot nz)
    • Field Detail

      • m_CaseSensitive

        protected boolean m_CaseSensitive
        whether to compare the files case-sensitive.
      • m_OnlyName

        protected boolean m_OnlyName
        whether to compare only the name, not the path.
    • Constructor Detail

      • FileComparator

        public FileComparator​(boolean caseSensitive,
                              boolean onlyName)
        Initializes the comparator.
        Parameters:
        caseSensitive - whether to perform case-sensitive comparison
        onlyName - whether to compare only the name
    • Method Detail

      • compare

        public int compare​(File o1,
                           File o2)
        Compares its two arguments for order. Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

        In the foregoing description, the notation sgn(expression) designates the mathematical signum function, which is defined to return one of -1, 0, or 1 according to whether the value of expression is negative, zero or positive.

        Specified by:
        compare in interface Comparator<File>
        Parameters:
        o1 - the first object to be compared.
        o2 - the second object to be compared.
        Returns:
        a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.
        Throws:
        ClassCastException - if the arguments' types prevent them from being compared by this comparator.