public class RMSort extends RMObject
RMSort titleFirst = new RMSort("getTitle"); RMSort bestRevenueFirst = new RMSort("getRevenue", ORDER_DESCEND);
This class also provides useful static methods for comparison and sorting:
RMSort.sort(myList, "getTitle"); // Sort myList by its contents' getTitle method (alphabetically) RMSort.sort(myList, bestRevenueFirst); // Sort myList by its contents' getRevenue method (largest first) List mySortList = new ArrayList(); mySortList.add(bestRevenueFirst); mySortList.add(titleFirst); RMSort.sort(myList, mySortList); // Sort myList by revenue and title
Modifier and Type | Field and Description |
---|---|
static java.util.Comparator |
COMPARATOR |
static byte |
ORDER_ASCEND |
static byte |
ORDER_DESCEND |
static byte |
ORDER_INDETERMINATE |
static byte |
ORDER_SAME |
Constructor and Description |
---|
RMSort()
Creates a plain sort with no key.
|
RMSort(java.lang.String aKey)
Creates a sort with the given key and ORDER_ASCEND.
|
RMSort(java.lang.String aKey,
int anOrder)
Creates a sort with the given key and order.
|
Modifier and Type | Method and Description |
---|---|
static int |
compare(java.lang.Object obj1,
java.lang.Object obj2)
Compare two value objects (assumed to be String, Numer, Boolean, Date, Comparable, etc.).
|
static int |
compare(java.lang.Object obj1,
java.lang.Object obj2,
java.util.List aSortList)
Compare objects with given list of RMSorts.
|
static int |
compare(java.lang.Object obj1,
java.lang.Object obj2,
RMSort aSort)
Compare objects with given RMSort.
|
boolean |
equals(java.lang.Object anObj)
Standard equals implementation.
|
void |
flip()
Deprecated - use getFlipped instead, RMSort should be immutable.
|
java.lang.Object |
fromXML(RXArchiver anArchiver,
RXElement anElement)
XML unarchival.
|
RMSort |
getFlipped()
Returns a sort with the same key but opposite order.
|
java.lang.String |
getKey()
Returns the _key for this sort.
|
int |
getOrder()
Returns the order for this sort.
|
java.lang.Object |
initWithArchiver(RMArchiver anArchiver)
Legacy unarchival.
|
static java.util.List |
sort(java.util.List aList,
java.util.List aSortList)
Returns the given list sorted by the given list of sorts.
|
static java.util.List |
sort(java.util.List aList,
RMSort aSort)
Returns the given list sorted by the given sort.
|
static java.util.List |
sort(java.util.List aList,
java.lang.String aKey)
Returns the given list sorted by the given key.
|
static java.util.Vector |
sortedList(java.util.List aList,
java.lang.String aKey)
Returns a new list from the given list sorted by the given key.
|
java.lang.String |
toString()
Returns a string representation of sort (just the sort key).
|
RXElement |
toXML(RXArchiver anArchiver)
XML archival.
|
clone, copy, didChange, didUndo, getAnimAttribute, getClassNameShort, undoClone, undoCopy, undoEquals
public static final byte ORDER_SAME
public static final byte ORDER_ASCEND
public static final byte ORDER_DESCEND
public static final byte ORDER_INDETERMINATE
public static java.util.Comparator COMPARATOR
public RMSort()
public RMSort(java.lang.String aKey)
public RMSort(java.lang.String aKey, int anOrder)
public java.lang.String getKey()
public int getOrder()
public RMSort getFlipped()
public void flip()
public static int compare(java.lang.Object obj1, java.lang.Object obj2, RMSort aSort)
public static int compare(java.lang.Object obj1, java.lang.Object obj2, java.util.List aSortList)
public static int compare(java.lang.Object obj1, java.lang.Object obj2)
public static java.util.List sort(java.util.List aList, java.lang.String aKey)
public static java.util.List sort(java.util.List aList, RMSort aSort)
public static java.util.List sort(java.util.List aList, java.util.List aSortList)
public static java.util.Vector sortedList(java.util.List aList, java.lang.String aKey)
public boolean equals(java.lang.Object anObj)
equals
in class java.lang.Object
public java.lang.String toString()
toString
in class java.lang.Object
public RXElement toXML(RXArchiver anArchiver)
public java.lang.Object fromXML(RXArchiver anArchiver, RXElement anElement)
public java.lang.Object initWithArchiver(RMArchiver anArchiver)
initWithArchiver
in interface RMArchiver.Archiving
initWithArchiver
in class RMObject