Package com.reportmill.base
Class RMSort
java.lang.Object
com.reportmill.base.RMObject
com.reportmill.base.RMSort
- All Implemented Interfaces:
RMArchiver.Archiving
,Cloneable
This class provides a basic description for comparison and sorting with a simple key and order (ascending or
descending). You can create a new order like this:
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
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic Comparator
static final byte
static final byte
static final byte
static final byte
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic int
Compare two value objects (assumed to be String, Numer, Boolean, Date, Comparable, etc.).static int
Compare objects with given RMSort.static int
Compare objects with given list of RMSorts.boolean
Standard equals implementation.void
flip()
Deprecated - use getFlipped instead, RMSort should be immutable.fromXML
(RXArchiver anArchiver, RXElement anElement) XML unarchival.Returns a sort with the same key but opposite order.getKey()
Returns the _key for this sort.int
getOrder()
Returns the order for this sort.initWithArchiver
(RMArchiver anArchiver) Legacy unarchival.static List
Returns the given list sorted by the given sort.static List
Returns the given list sorted by the given key.static List
Returns the given list sorted by the given list of sorts.static Vector
sortedList
(List aList, String aKey) Returns a new list from the given list sorted by the given key.toString()
Returns a string representation of sort (just the sort key).toXML
(RXArchiver anArchiver) XML archival.Methods inherited from class com.reportmill.base.RMObject
clone, copy, didChange, didUndo, getAnimAttribute, getClassNameShort, undoClone, undoCopy, undoEquals
-
Field Details
-
ORDER_SAME
public static final byte ORDER_SAME- See Also:
-
ORDER_ASCEND
public static final byte ORDER_ASCEND- See Also:
-
ORDER_DESCEND
public static final byte ORDER_DESCEND- See Also:
-
ORDER_INDETERMINATE
public static final byte ORDER_INDETERMINATE- See Also:
-
COMPARATOR
-
-
Constructor Details
-
RMSort
public RMSort()Creates a plain sort with no key. Used for unarchival, shouldn't be called directly. -
RMSort
Creates a sort with the given key and ORDER_ASCEND. -
RMSort
Creates a sort with the given key and order.
-
-
Method Details
-
getKey
Returns the _key for this sort. -
getOrder
public int getOrder()Returns the order for this sort. -
getFlipped
Returns a sort with the same key but opposite order. -
flip
public void flip()Deprecated - use getFlipped instead, RMSort should be immutable. -
compare
Compare objects with given RMSort. -
compare
Compare objects with given list of RMSorts. -
compare
Compare two value objects (assumed to be String, Numer, Boolean, Date, Comparable, etc.). -
sort
Returns the given list sorted by the given key. -
sort
Returns the given list sorted by the given sort. -
sort
Returns the given list sorted by the given list of sorts. -
sortedList
Returns a new list from the given list sorted by the given key. -
equals
Standard equals implementation. -
toString
Returns a string representation of sort (just the sort key). -
toXML
XML archival. -
fromXML
XML unarchival. -
initWithArchiver
Legacy unarchival.- Specified by:
initWithArchiver
in interfaceRMArchiver.Archiving
- Overrides:
initWithArchiver
in classRMObject
-