DLESE Tools
v1.2

org.dlese.dpc.index
Class DateFieldComparator

java.lang.Object
  extended byorg.dlese.dpc.index.DateFieldComparator
All Implemented Interfaces:
Comparator

public class DateFieldComparator
extends Object
implements Comparator

Compares two ResultDocs for sorting by date. A DateField must have been encoded and stored in the underlying Document of the ResultDoc. The name of the field that holds the date is passed into the constructor of this DateFieldComparator.

Author:
John Weatherley
See Also:
ResultDoc, DateField

Field Summary
static int ASCENDING
          Used to sort in ascending order by date.
static int DESCENDING
          Used to sort in descending order by date.
 
Constructor Summary
DateFieldComparator(String dateFieldName, int sortOrder)
          Constructor for this DateFieldComparator object.
 
Method Summary
 int compare(Object o1, Object o2)
          Compares two ResultDocs for sorting by a date field, indicated at construction time.
 
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
 

Field Detail

ASCENDING

public static final int ASCENDING
Used to sort in ascending order by date.

See Also:
Constant Field Values

DESCENDING

public static final int DESCENDING
Used to sort in descending order by date.

See Also:
Constant Field Values
Constructor Detail

DateFieldComparator

public DateFieldComparator(String dateFieldName,
                           int sortOrder)
Constructor for this DateFieldComparator object.

Parameters:
dateFieldName - The name of the field that holds the date.
sortOrder - Determines the order of sorting (ASCENDING or DESCENDING).
Method Detail

compare

public int compare(Object o1,
                   Object o2)
Compares two ResultDocs for sorting by a date field, indicated at construction time.

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

DLESE Tools
v1.2