org.jdesktop.swingx.decorator
Class SortKey

java.lang.Object
  extended by org.jdesktop.swingx.decorator.SortKey

public class SortKey
extends Object

A column and how its sorted.


Constructor Summary
SortKey(SortOrder sortOrder, int column)
           
SortKey(SortOrder sortOrder, int column, Comparator comparator)
           
 
Method Summary
 boolean equals(Object o)
          Indicates whether some other object is "equal to" this one.
 int getColumn()
          The sorting column in terms of model index.
 Comparator getComparator()
          The comparator to use, might be null.
static SortKey getFirstSortingKey(List<? extends SortKey> keys)
          Returns the first SortKey in the list which is sorted.
static SortKey getFirstSortKeyForColumn(List<? extends SortKey> keys, int modelColumn)
          Returns the first SortKey in the list for the given column, or null if the column has no SortKey.
 SortOrder getSortOrder()
          The sort order, ascending, descending or unsorted.
 int hashCode()
          Returns a hash code value for the object.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortKey

public SortKey(SortOrder sortOrder,
               int column)
Parameters:
sortOrder - one of SortOrder.ASCENDING, SortOrder.DESCENDING or SortOrder.UNSORTED.
column - a column in terms of model index.

SortKey

public SortKey(SortOrder sortOrder,
               int column,
               Comparator comparator)
Parameters:
sortOrder - one of SortOrder.ASCENDING, SortOrder.DESCENDING or SortOrder.UNSORTED.
column - a column in terms of model index.
comparator - the comparator to use with this sort.
Method Detail

getSortOrder

public SortOrder getSortOrder()
The sort order, ascending, descending or unsorted.


getColumn

public int getColumn()
The sorting column in terms of model index.


getComparator

public Comparator getComparator()
The comparator to use, might be null.


equals

public boolean equals(Object o)
Indicates whether some other object is "equal to" this one.

The equals method implements an equivalence relation on non-null object references:

The equals method for class Object implements the most discriminating possible equivalence relation on objects; that is, for any non-null reference values x and y, this method returns true if and only if x and y refer to the same object (x == y has the value true).

Note that it is generally necessary to override the hashCode method whenever this method is overridden, so as to maintain the general contract for the hashCode method, which states that equal objects must have equal hash codes.

Overrides:
equals in class Object
Parameters:
o - the reference object with which to compare.
Returns:
true if this object is the same as the obj argument; false otherwise.
See Also:
Object.hashCode(), Hashtable

hashCode

public int hashCode()
Returns a hash code value for the object. This method is supported for the benefit of hashtables such as those provided by java.util.Hashtable.

The general contract of hashCode is:

As much as is reasonably practical, the hashCode method defined by class Object does return distinct integers for distinct objects. (This is typically implemented by converting the internal address of the object into an integer, but this implementation technique is not required by the JavaTM programming language.)

Overrides:
hashCode in class Object
Returns:
a hash code value for this object.
See Also:
Object.equals(java.lang.Object), Hashtable

getFirstSortingKey

public static SortKey getFirstSortingKey(List<? extends SortKey> keys)
Returns the first SortKey in the list which is sorted. If none is sorted, null is returned.

Parameters:
keys - a list of SortKeys to search
Returns:
the first SortKey which is sorted or null, if no is found.

getFirstSortKeyForColumn

public static SortKey getFirstSortKeyForColumn(List<? extends SortKey> keys,
                                               int modelColumn)
Returns the first SortKey in the list for the given column, or null if the column has no SortKey.

Parameters:
keys - a list of SortKeys to search
modelColumn - the column index in model coordinates
Returns:
the first SortKey for the given column or null if none is found.