org.apache.beehive.netui.databinding.datagrid.api.sort
Class SortModel

Object
  extended by SortModel
All Implemented Interfaces:
Serializable

public class SortModel
extends Object
implements Serializable

The SortModel class groups a set of Sort objects. This class also provides a set of methods for interacting with a group of Sort objects.

The list of Sort objects in a SortModel are ordered. The first sort in group is known as the "primary" sort and subsequent Sorts are "secondary". The interpretation of using Sorts into to order a data set is left to implementations of sort algoritms. For example, one possible sort implementation could order the sorts such that the secondary sort occurs inside the data ordered by the primary sort and so on.

In addition to accessing the Sort objects, the SortModel provides a the ability to plug a simple state machine that controls how to change a sort direction when cycling through the set of sort directions. For example, when using a data grid to sort columns of data, a column may start off unsorted, change to SortDirection.ASCENDING, to SortDirection.DESCENDING, and finally back to SortDirection.NONE. The SortStrategy allows this strategy to be changed so that the sorts can change from SortDirection.NONE to SortDirection.DESCENDING, to SortDirection.ASCENDING, and finally back to SortDirection.NONE.

See Also:
Serialized Form

Constructor Summary
SortModel(List sorts)
          Construct the SortModel with a List of sorts.
 
Method Summary
 SortDirection getSortDirection(String sortExpression)
          Get the SortDirection for a Sort given a sort expression.
 List getSorts()
           
 SortStrategy getSortStrategy()
          Get the SortStrategy used to cycle these Sort objects through various SortDirections.
 boolean isPrimarySort(String sortExpression)
          Check to see if a sort expression is the first Sort in the SortModel.
 boolean isSorted(String sortExpression)
          Check to see if the SortModel contains a Sort whose sort expression matches the given sortExpression.
 Sort lookupSort(String sortExpression)
          Lookup a Sort object whose Sort.getSortExpression() matches the given sortExpression.
 void setSortStrategy(SortStrategy sortStrategy)
          Set the SortStrategy.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortModel

public SortModel(List sorts)
Construct the SortModel with a List of sorts.

Parameters:
sorts - the sorts
Method Detail

getSortStrategy

public SortStrategy getSortStrategy()
Get the SortStrategy used to cycle these Sort objects through various SortDirections.

Returns:
the SortStrategy

setSortStrategy

public void setSortStrategy(SortStrategy sortStrategy)
Set the SortStrategy.

Parameters:
sortStrategy - the new SortStrategy

getSorts

public List getSorts()

isPrimarySort

public boolean isPrimarySort(String sortExpression)
Check to see if a sort expression is the first Sort in the SortModel. If the first Sort in the SortModel has a Sort.getSortExpression() that matches the sortExpression parameter, the method returns true. Otherwise, it returns false.

Parameters:
sortExpression - the sort expression to use when checking the SortModel's first Sort
Returns:
true if the first Sort has a sortExpression that matches the sortExpression parameter. false otherwise.

isSorted

public boolean isSorted(String sortExpression)
Check to see if the SortModel contains a Sort whose sort expression matches the given sortExpression.

Parameters:
sortExpression - the sortExpression used to locate a Sort
Returns:
true if a Sort is found whose Sort.getSortExpression() matches the given sortExpression. false otherwise.

getSortDirection

public SortDirection getSortDirection(String sortExpression)
Get the SortDirection for a Sort given a sort expression.

Parameters:
sortExpression - the sort expression used to locate a Sort object.
Returns:
a Sort's SortDirection if one is found whose sortExpression property matches the given sortExpression. null otherwise.

lookupSort

public Sort lookupSort(String sortExpression)
Lookup a Sort object whose Sort.getSortExpression() matches the given sortExpression.

Parameters:
sortExpression - the sortExpression used to locate a Sort
Returns:
a Sort if one is found whose sortExpression property matches the given sortExpression. null otherwise.