org.directwebremoting.io
Class SortCriterion

java.lang.Object
  extended by org.directwebremoting.io.SortCriterion

public class SortCriterion
extends java.lang.Object

A SortCriterion describes one facet of a possible way of sorting some data. It will generally be used as a List<SortCriterion>. So the data is sorted by the fist SortCriterion in the list first, turning to the second only if there is an equals scenario between 2 bits of data. It is assumed that values for each attribute can be extracted from the data. This is generally fairly simple for Maps and Pojos. SortCriterion does not specify a Comparator. It is assumed that the values stored by the data against each attribute are either Comparable or that the system can find a Comparator

Pomposity alert: I wouldn't normally be pedantic about Criteria/Criterion, but it's important to note that this is just one facet of an instruction to a sorting algorithm, and not the entire instruction.

Author:
Joe Walker [joe at getahead dot ltd dot uk]

Constructor Summary
SortCriterion(java.lang.String attribute, boolean descending)
          All SortCriterion need an attribute and sort order.
 
Method Summary
 boolean equals(java.lang.Object obj)
           
 java.lang.String getAttribute()
          The attribute points to a data member within the data to be sorted.
 int hashCode()
           
 boolean isAscending()
          Are we sorting in ascending order? This is the logical negative of isDescending()
 boolean isDescending()
          Are we sorting in descending order?
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SortCriterion

public SortCriterion(java.lang.String attribute,
                     boolean descending)
All SortCriterion need an attribute and sort order.

Method Detail

getAttribute

public java.lang.String getAttribute()
The attribute points to a data member within the data to be sorted. If the data is a Map this will be a key. If the data is a Pojo, it will be a property.

Returns:
The name of the data member to sort

isDescending

public boolean isDescending()
Are we sorting in descending order?


isAscending

public boolean isAscending()
Are we sorting in ascending order? This is the logical negative of isDescending()


hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object obj)
Overrides:
equals in class java.lang.Object

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

Copyright 2008