Class FileModDateComparator

java.lang.Object
org.dlese.dpc.util.FileModDateComparator
All Implemented Interfaces:
Comparator

public class FileModDateComparator extends Object implements Comparator
Compares two Files based on their modification date.
Version:
$Id: FileModDateComparator.java,v 1.2 2009/03/20 23:34:00 jweather Exp $
Author:
John Weatherley
  • Field Details

    • NEWEST_FIRST

      public static final int NEWEST_FIRST
      Sort by newest first.
      See Also:
    • OLDEST_FIRST

      public static final int OLDEST_FIRST
      Sort by oldest first.
      See Also:
  • Constructor Details

    • FileModDateComparator

      public FileModDateComparator(int sortOrder)
      Constructor that allows setting the sort order by newest or oldest first.
      Parameters:
      sortOrder - The order for sorting (NEWEST_FIRST or OLDEST_FIRST)
      See Also:
    • FileModDateComparator

      public FileModDateComparator()
      Default constructor that sorts by newest first.
  • Method Details

    • compare

      public int compare(Object o1, Object o2)
      Compares two Files for sorting by their modification date.

      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.

      Specified by:
      compare in interface Comparator
      Parameters:
      o1 - The first Object.
      o2 - The second Object.
      Returns:
      An int indicating sort order.