Package com.inductiveautomation.rm.base
Class RMSort
java.lang.Object
com.inductiveautomation.rm.base.RMSort
- All Implemented Interfaces:
- Archivable,- RMJSONArchiver.GetKeys,- Cloneable,- Comparator
- Direct Known Subclasses:
- RMTopNSort,- RMValueSort
public class RMSort
extends Object
implements Comparator, Cloneable, RMJSONArchiver.GetKeys, Archivable
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 TypeMethodDescriptionclone()Standard clone implementation.intReturns how the two given objects compare with this sort.static intCompare two value objects (assumed to be String, Number, Boolean, Date, Comparable, etc.).booleanStandard equals implementation.fromXML(RXArchiver anArchiver, RXElement anElement) XML unarchival.RMJSONArchiver GetKeys method.getKey()Returns the key for this sort.intgetOrder()Returns the order for this sort.intReturns the order default.Returns the order as a string.voidSets the key for this sort.voidsetOrder(int anOrder) Sets the order for this sort.voidsetOrderString(String aString) Sets the order as a string.static voidReturns the given list sorted by the given sort.static voidReturns the given list sorted by the given sort.static voidReturns the given list sorted by the given key.static voidReturns the given list sorted by the given key.static voidReturns the given list sorted by the given list of sorts.static <T extends Comparable<? super T>>
 List<T>sortedList(Collection<T> aCollection) Returns a new sorted list from given collection.static <T> Vector<T>sortedList(Collection<T> aCollection, String aKey) Returns a new list from the given list sorted by the given key.static <T> Vector<T>sortedList(Collection<T> aCollection, String... theKeys) Returns a new list from the given list sorted by the given key.voidToggles the order for this sort between ORDER_ASCEND<->ORDER_DESCEND.toString()Returns a string representation of sort (just the sort key).toXML(RXArchiver anArchiver) XML archival.Methods inherited from class java.lang.Objectfinalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.util.Comparatorreversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
- 
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.
- 
setKeySets the key for this sort.
- 
getOrderpublic int getOrder()Returns the order for this sort.
- 
setOrderpublic void setOrder(int anOrder) Sets the order for this sort.
- 
getOrderDefaultpublic int getOrderDefault()Returns the order default.
- 
getOrderStringReturns the order as a string.
- 
setOrderStringSets the order as a string.
- 
toggleOrderpublic void toggleOrder()Toggles the order for this sort between ORDER_ASCEND<->ORDER_DESCEND.
- 
compareReturns how the two given objects compare with this sort.- Specified by:
- comparein interface- Comparator
 
- 
CompareCompare two value objects (assumed to be String, Number, 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 key.
- 
sortReturns the given list sorted by the given sort.
- 
sortReturns the given list sorted by the given list of sorts.
- 
sortedListReturns a new sorted list from given collection.
- 
sortedListReturns a new list from the given list sorted by the given key.
- 
sortedListReturns a new list from the given list sorted by the given key.
- 
equalsStandard equals implementation.- Specified by:
- equalsin interface- Comparator
- Overrides:
- equalsin class- Object
 
- 
cloneStandard clone implementation.
- 
getJSONKeysRMJSONArchiver GetKeys method.- Specified by:
- getJSONKeysin interface- RMJSONArchiver.GetKeys
 
- 
toXMLXML archival.- Specified by:
- toXMLin interface- Archivable
 
- 
fromXMLXML unarchival.- Specified by:
- fromXMLin interface- Archivable
 
- 
toStringReturns a string representation of sort (just the sort key).
 
-