org.afcs.warts.db
Class KeyComparator

java.lang.Object
  extended byorg.afcs.warts.db.KeyComparator
All Implemented Interfaces:
java.util.Comparator

public final class KeyComparator
extends java.lang.Object
implements java.util.Comparator

The KeyComparator class provides a singleton instance that can be used to compare lists of objects based on their own intrinsic Comparable properties, or their string values if all else fails. Lists of objects are, of course, what are used to store primary key values in DataSet.

LICENSE: This code is released to the public domain and may be used for any purpose whatsoever without permission or acknowledgment.

Version:
Last Modified 15 October 2003
Author:
Warren Hedley ( whedley at sdsc dot edu )

Field Summary
static java.util.Comparator KEY_COMPARATOR
          The singleton instance that should be used to perform primary key comparisons.
 
Method Summary
 int compare(java.lang.Object o1, java.lang.Object o2)
          Compares to non-null java.util.List instances, returning am integer that can be used to sort them into ascending order based on their own Comparable properties, or if they don't implement Comparable, their string values.
 
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

KEY_COMPARATOR

public static final java.util.Comparator KEY_COMPARATOR
The singleton instance that should be used to perform primary key comparisons.

Method Detail

compare

public int compare(java.lang.Object o1,
                   java.lang.Object o2)
Compares to non-null java.util.List instances, returning am integer that can be used to sort them into ascending order based on their own Comparable properties, or if they don't implement Comparable, their string values.

Specified by:
compare in interface java.util.Comparator
Parameters:
o1 - The first object to consider.
o2 - The second object to consider.
Returns:
An integer that can be used to sort a list of lists into ascending order.
Throws:
java.lang.IllegalArgumentException - If either object is null or not a java.util.List instance.