com.martiansoftware.trivialpersist.helpers
Class FieldComparator

java.lang.Object
  extended bycom.martiansoftware.trivialpersist.helpers.FieldComparator
All Implemented Interfaces:
Comparator

public class FieldComparator
extends Object
implements Comparator

A simple field-based comparator that can be used in selects.

Author:
Marty Lamb

Field Summary
static int ORDER_ASCENDING
          Instructs the comparator to return results in ASCENDING order
static int ORDER_DESCENDING
          Instructs the comparator to return results in DESCENDING order
 
Constructor Summary
FieldComparator(String fieldName)
          Creates a new FieldComparator for the specified field in ascending order
FieldComparator(String fieldName, int order)
          Creates a new FieldComparator for the specified field in the specified order
 
Method Summary
 int compare(Object o1, Object o2)
          Performs the field comparison
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface java.util.Comparator
equals
 

Field Detail

ORDER_ASCENDING

public static final int ORDER_ASCENDING
Instructs the comparator to return results in ASCENDING order

See Also:
Constant Field Values

ORDER_DESCENDING

public static final int ORDER_DESCENDING
Instructs the comparator to return results in DESCENDING order

See Also:
Constant Field Values
Constructor Detail

FieldComparator

public FieldComparator(String fieldName)
Creates a new FieldComparator for the specified field in ascending order

Parameters:
fieldName - the name of the field to examine

FieldComparator

public FieldComparator(String fieldName,
                       int order)
Creates a new FieldComparator for the specified field in the specified order

Parameters:
fieldName - the name of the field to examine
order - must be either ORDER_ASCENDING or ORDER_DESCENDING
Method Detail

compare

public int compare(Object o1,
                   Object o2)
Performs the field comparison

Specified by:
compare in interface Comparator
Parameters:
o1 - the first Record to compare
o2 - the second Record to compare


Copyright © 2004, Martian Software, Inc.. All Rights Reserved.
For the latest version and documentation, please visit http://www.martiansoftware.com/trivialpersist