| java.lang.Object org.springframework.util.comparator.CompoundComparator
CompoundComparator | public class CompoundComparator implements Comparator,Serializable(Code) | | A comparator that chains a sequence of one or more more Comparators.
A compound comparator calls each Comparator in sequence until a single
Comparator returns a non-zero result, or the comparators are exhausted and
zero is returned.
This facilitates in-memory sorting similar to multi-column sorting in SQL.
The order of any single Comparator in the list can also be reversed.
author: Keith Donald author: Juergen Hoeller since: 1.2.2 |
Constructor Summary | |
public | CompoundComparator() Construct a CompoundComparator with initially no Comparators. | public | CompoundComparator(Comparator[] comparators) Construct a CompoundComparator from the Comparators in the provided array. |
CompoundComparator | public CompoundComparator()(Code) | | Construct a CompoundComparator with initially no Comparators. Clients
must add at least one Comparator before calling the compare method or an
IllegalStateException is thrown.
|
CompoundComparator | public CompoundComparator(Comparator[] comparators)(Code) | | Construct a CompoundComparator from the Comparators in the provided array.
All Comparators will default to ascending sort order,
unless they are InvertibleComparators.
Parameters: comparators - the comparators to build into a compound comparator See Also: InvertibleComparator |
addComparator | public void addComparator(Comparator comparator)(Code) | | Add a Comparator to the end of the chain.
The Comparator will default to ascending sort order,
unless it is a InvertibleComparator.
Parameters: comparator - the Comparator to add to the end of the chain See Also: InvertibleComparator |
addComparator | public void addComparator(Comparator comparator, boolean ascending)(Code) | | Add a Comparator to the end of the chain using the provided sort order.
Parameters: comparator - the Comparator to add to the end of the chain Parameters: ascending - the sort order: ascending (true) or descending (false) |
getComparatorCount | public int getComparatorCount()(Code) | | Returns the number of aggregated comparators.
|
hashCode | public int hashCode()(Code) | | |
invertOrder | public void invertOrder()(Code) | | Invert the sort order of each sort definition contained by this compound
comparator.
|
invertOrder | public void invertOrder(int index)(Code) | | Invert the sort order of the sort definition at the specified index.
Parameters: index - the index of the comparator to invert |
setAscendingOrder | public void setAscendingOrder(int index)(Code) | | Change the sort order at the given index to ascending.
Parameters: index - the index of the comparator to change |
setComparator | public void setComparator(int index, Comparator comparator)(Code) | | Replace the Comparator at the given index.
The Comparator will default to ascending sort order,
unless it is a InvertibleComparator.
Parameters: index - the index of the Comparator to replace Parameters: comparator - the Comparator to place at the given index See Also: InvertibleComparator |
setComparator | public void setComparator(int index, Comparator comparator, boolean ascending)(Code) | | Replace the Comparator at the given index using the given sort order.
Parameters: index - the index of the Comparator to replace Parameters: comparator - the Comparator to place at the given index Parameters: ascending - the sort order: ascending (true) or descending (false) |
setDescendingOrder | public void setDescendingOrder(int index)(Code) | | Change the sort order at the given index to descending sort.
Parameters: index - the index of the comparator to change |
|
|