Package com.reportmill.base
Class RMSort
- java.lang.Object
- 
- com.reportmill.base.RMObject
- 
- com.reportmill.base.RMSort
 
 
- 
- All Implemented Interfaces:
- RMArchiver.Archiving,- java.lang.Cloneable
 
 public class RMSort extends RMObject 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 SummaryFields Modifier and Type Field Description static java.util.ComparatorCOMPARATORstatic byteORDER_ASCENDstatic byteORDER_DESCENDstatic byteORDER_INDETERMINATEstatic byteORDER_SAME
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static intcompare(java.lang.Object obj1, java.lang.Object obj2)Compare two value objects (assumed to be String, Numer, Boolean, Date, Comparable, etc.).static intcompare(java.lang.Object obj1, java.lang.Object obj2, RMSort aSort)Compare objects with given RMSort.static intcompare(java.lang.Object obj1, java.lang.Object obj2, java.util.List aSortList)Compare objects with given list of RMSorts.booleanequals(java.lang.Object anObj)Standard equals implementation.voidflip()Deprecated - use getFlipped instead, RMSort should be immutable.java.lang.ObjectfromXML(RXArchiver anArchiver, RXElement anElement)XML unarchival.RMSortgetFlipped()Returns a sort with the same key but opposite order.java.lang.StringgetKey()Returns the _key for this sort.intgetOrder()Returns the order for this sort.java.lang.ObjectinitWithArchiver(RMArchiver anArchiver)Legacy unarchival.static java.util.Listsort(java.util.List aList, RMSort aSort)Returns the given list sorted by the given sort.static java.util.Listsort(java.util.List aList, java.lang.String aKey)Returns the given list sorted by the given key.static java.util.Listsort(java.util.List aList, java.util.List aSortList)Returns the given list sorted by the given list of sorts.static java.util.VectorsortedList(java.util.List aList, java.lang.String aKey)Returns a new list from the given list sorted by the given key.java.lang.StringtoString()Returns a string representation of sort (just the sort key).RXElementtoXML(RXArchiver anArchiver)XML archival.- 
Methods inherited from class com.reportmill.base.RMObjectclone, copy, didChange, didUndo, getAnimAttribute, getClassNameShort, undoClone, undoCopy, undoEquals
 
- 
 
- 
- 
- 
Field Detail- 
ORDER_SAMEpublic static final byte ORDER_SAME - See Also:
- Constant Field Values
 
 - 
ORDER_ASCENDpublic static final byte ORDER_ASCEND - See Also:
- Constant Field Values
 
 - 
ORDER_DESCENDpublic static final byte ORDER_DESCEND - See Also:
- Constant Field Values
 
 - 
ORDER_INDETERMINATEpublic static final byte ORDER_INDETERMINATE - See Also:
- Constant Field Values
 
 - 
COMPARATORpublic static java.util.Comparator COMPARATOR 
 
- 
 - 
Constructor Detail- 
RMSortpublic RMSort() Creates a plain sort with no key. Used for unarchival, shouldn't be called directly.
 - 
RMSortpublic RMSort(java.lang.String aKey) Creates a sort with the given key and ORDER_ASCEND.
 - 
RMSortpublic RMSort(java.lang.String aKey, int anOrder)Creates a sort with the given key and order.
 
- 
 - 
Method Detail- 
getKeypublic java.lang.String getKey() Returns the _key for this sort.
 - 
getOrderpublic int getOrder() Returns the order for this sort.
 - 
getFlippedpublic RMSort getFlipped() Returns a sort with the same key but opposite order.
 - 
flippublic void flip() Deprecated - use getFlipped instead, RMSort should be immutable.
 - 
comparepublic static int compare(java.lang.Object obj1, java.lang.Object obj2, RMSort aSort)Compare objects with given RMSort.
 - 
comparepublic static int compare(java.lang.Object obj1, java.lang.Object obj2, java.util.List aSortList)Compare objects with given list of RMSorts.
 - 
comparepublic static int compare(java.lang.Object obj1, java.lang.Object obj2)Compare two value objects (assumed to be String, Numer, Boolean, Date, Comparable, etc.).
 - 
sortpublic static java.util.List sort(java.util.List aList, java.lang.String aKey)Returns the given list sorted by the given key.
 - 
sortpublic static java.util.List sort(java.util.List aList, RMSort aSort)Returns the given list sorted by the given sort.
 - 
sortpublic static java.util.List sort(java.util.List aList, java.util.List aSortList)Returns the given list sorted by the given list of sorts.
 - 
sortedListpublic 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.
 - 
equalspublic boolean equals(java.lang.Object anObj) Standard equals implementation.- Overrides:
- equalsin class- java.lang.Object
 
 - 
toStringpublic java.lang.String toString() Returns a string representation of sort (just the sort key).- Overrides:
- toStringin class- java.lang.Object
 
 - 
toXMLpublic RXElement toXML(RXArchiver anArchiver) XML archival.
 - 
fromXMLpublic java.lang.Object fromXML(RXArchiver anArchiver, RXElement anElement) XML unarchival.
 - 
initWithArchiverpublic java.lang.Object initWithArchiver(RMArchiver anArchiver) Legacy unarchival.- Specified by:
- initWithArchiverin interface- RMArchiver.Archiving
- Overrides:
- initWithArchiverin class- RMObject
 
 
- 
 
-