net.sourceforge.floggy.persistence
Interface Comparator


public interface Comparator

An interface defining a comparator which compares two objects (in an implementation-defined manner) to see if they match or what their relative sort order is. The application implements this interface to compare two candidate objects. The return value must indicate the ordering of the two records.
The compare method is called by PersistableManager to sort the results of a search.

Since:
1.0
See Also:
PersistableManager.find(Class, Filter, Comparator), Filter

Field Summary
static int EQUIVALENT
          EQUIVALENT means that in terms of search or sort order, the two objects are the same.
static int FOLLOWS
          FOLLOWS means that the left (first parameter) object follows the right (second parameter) object in terms of search or sort order.

The value of FOLLOWS is 1.
static int PRECEDES
          PRECEDES means that the left (first parameter) object precedes the right (second parameter) object in terms of search or sort order.

The value of PRECEDES is -1.
 
Method Summary
 int compare(Persistable o1, Persistable o2)
          Returns Comparator.PRECEDES if o1 precedes o2 in sort order, or Comparator.FOLLOWS if o1 follows o2 in sort order, or Comparator.EQUIVALENT if o1 and o2 are equivalent in terms of sort order.
 

Field Detail

EQUIVALENT

static final int EQUIVALENT
EQUIVALENT means that in terms of search or sort order, the two objects are the same. This does not necessarily mean that the two objects are identical.

The value of EQUIVALENT is 0.

See Also:
Constant Field Values

FOLLOWS

static final int FOLLOWS
FOLLOWS means that the left (first parameter) object follows the right (second parameter) object in terms of search or sort order.

The value of FOLLOWS is 1.

See Also:
Constant Field Values

PRECEDES

static final int PRECEDES
PRECEDES means that the left (first parameter) object precedes the right (second parameter) object in terms of search or sort order.

The value of PRECEDES is -1.

See Also:
Constant Field Values
Method Detail

compare

int compare(Persistable o1,
            Persistable o2)
Returns Comparator.PRECEDES if o1 precedes o2 in sort order, or Comparator.FOLLOWS if o1 follows o2 in sort order, or Comparator.EQUIVALENT if o1 and o2 are equivalent in terms of sort order.

Parameters:
o1 - The first object for comparison.
o2 - The second object for comparison.
Returns:
Comparator.PRECEDES if o1 precedes o2 in sort order, or Comparator.FOLLOWS if o1 follows o2 in sort order, or Comparator.EQUIVALENT if o1 and o2 are equivalent in terms of sort order.


Copyright © 2006-2011 Floggy Open Source Group. All Rights Reserved.