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 SummaryFieldsModifier and TypeFieldDescriptionstatic Comparatorstatic final bytestatic final bytestatic final bytestatic final byte
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionstatic intCompare two value objects (assumed to be String, Numer, Boolean, Date, Comparable, etc.).static intCompare objects with given RMSort.static intCompare objects with given list of RMSorts.booleanStandard equals implementation.voidflip()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.intgetOrder()Returns the order for this sort.initWithArchiver(RMArchiver anArchiver) Legacy unarchival.static ListReturns the given list sorted by the given sort.static ListReturns the given list sorted by the given key.static ListReturns the given list sorted by the given list of sorts.static VectorsortedList(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.RMObjectclone, copy, didChange, didUndo, getAnimAttribute, getClassNameShort, undoClone, undoCopy, undoEquals
- 
Field Details- 
ORDER_SAMEpublic static final byte ORDER_SAME- See Also:
 
- 
ORDER_ASCENDpublic static final byte ORDER_ASCEND- See Also:
 
- 
ORDER_DESCENDpublic static final byte ORDER_DESCEND- See Also:
 
- 
ORDER_INDETERMINATEpublic static final byte ORDER_INDETERMINATE- See Also:
 
- 
COMPARATOR
 
- 
- 
Constructor Details- 
RMSortpublic RMSort()Creates a plain sort with no key. Used for unarchival, shouldn't be called directly.
- 
RMSortCreates a sort with the given key and ORDER_ASCEND.
- 
RMSortCreates a sort with the given key and order.
 
- 
- 
Method Details- 
getKeyReturns the _key for this sort.
- 
getOrderpublic int getOrder()Returns the order for this sort.
- 
getFlippedReturns a sort with the same key but opposite order.
- 
flippublic void flip()Deprecated - use getFlipped instead, RMSort should be immutable.
- 
compareCompare objects with given RMSort.
- 
compareCompare objects with given list of RMSorts.
- 
compareCompare two value objects (assumed to be String, Numer, Boolean, Date, Comparable, etc.).
- 
sortReturns the given list sorted by the given key.
- 
sortReturns the given list sorted by the given sort.
- 
sortReturns the given list sorted by the given list of sorts.
- 
sortedListReturns a new list from the given list sorted by the given key.
- 
equalsStandard equals implementation.
- 
toStringReturns a string representation of sort (just the sort key).
- 
toXMLXML archival.
- 
fromXMLXML unarchival.
- 
initWithArchiverLegacy unarchival.- Specified by:
- initWithArchiverin interface- RMArchiver.Archiving
- Overrides:
- initWithArchiverin class- RMObject
 
 
-