|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object edu.nrao.sss.sort.SortKey<T>
public abstract class SortKey<T>
A single sorting key.
Version Info:
$Revision: 593 $ |
$Date: 2007-05-07 15:54:14 -0600 (Mon, 07 May 2007) $ |
$Author: dharland $ |
Constructor Summary | |
---|---|
protected |
SortKey()
Helps create a new key with a natural order. |
Method Summary | |
---|---|
protected abstract int |
compareAscending(T o1,
T o2)
Returns a number less than zero, zero, or greater than zero as o1 is before, coincident with, or after o2 when sorted in ascending order. |
protected abstract int |
compareNatural(T o1,
T o2)
Returns a number less than zero, zero, or greater than zero as o1 is before, coincident with, or after o2 when sorted in natural order. |
protected int |
compareObjects(T o1,
T o2)
Returns a number less than zero, zero, or greater than zero as o1 is before, coincident with, or after o2 when sorted in this key's current order. |
protected int |
compareObjects(T o1,
T o2,
SortOrder ordering)
Returns a number less than zero, zero, or greater than zero as o1 is before, coincident with, or after o2 when sorted in according to t he given sort order. |
SortOrder |
getOrder()
Returns the sort order. |
protected int |
nullOrdering(T o1,
T o2)
Handles comparisons when exactly one of the two objects is null. |
protected boolean |
objectsAreEqual(Object o1,
Object o2)
Returns true if the two objects are equal. |
void |
setOrder(SortOrder newOrder)
Sets the order to newOrder . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected SortKey()
Method Detail |
---|
public void setOrder(SortOrder newOrder)
Orderable
newOrder
.
Implementing classes should handle a null parameter in some way
other than merely saving it and waiting for a downstream
NullPointerException
. Typical responses would be to replace
null with some valid value, such as SortOrder.NATURAL
,
or to throw an IllegalArgumentException
.
setOrder
in interface Orderable
newOrder
- the new order for sorting.public SortOrder getOrder()
Orderable
Implementing classes should guarantee that the returned value will never be null.
getOrder
in interface Orderable
protected int compareObjects(T o1, T o2)
protected int compareObjects(T o1, T o2, SortOrder ordering)
protected abstract int compareNatural(T o1, T o2)
protected abstract int compareAscending(T o1, T o2)
protected boolean objectsAreEqual(Object o1, Object o2)
compareObjects(Object, Object)
.
protected int nullOrdering(T o1, T o2)
compareObjects(Object, Object)
.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |