|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.vaadin.data.util.DefaultItemSorter
public class DefaultItemSorter
Provides a default implementation of an ItemSorter. The
DefaultItemSorter adheres to the
Container.Sortable.sort(Object[], boolean[]) rules and sorts the container
according to the properties given using
#setSortProperties(Sortable, Object[], boolean[]).
A Comparator is used for comparing the individual Property
values. The comparator can be set using the constructor. If no comparator is
provided a default comparator is used.
| Nested Class Summary | |
|---|---|
static class |
DefaultItemSorter.DefaultPropertyValueComparator
Provides a default comparator used for comparing Property values. |
| Constructor Summary | |
|---|---|
DefaultItemSorter()
Constructs a DefaultItemSorter using the default Comparator
for comparing Propertyvalues. |
|
DefaultItemSorter(Comparator<Object> propertyValueComparator)
Constructs a DefaultItemSorter which uses the Comparator
indicated by the propertyValueComparator parameter for
comparing Propertyvalues. |
|
| Method Summary | |
|---|---|
int |
compare(Object o1,
Object o2)
Compares its two arguments for order. |
protected int |
compareProperty(Object propertyId,
boolean sortDirection,
Item item1,
Item item2)
Compares the property indicated by propertyId in the items
indicated by item1 and item2 for order. |
void |
setSortProperties(Container.Sortable container,
Object[] propertyId,
boolean[] ascending)
Sets the parameters for an upcoming sort operation. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface java.util.Comparator |
|---|
equals |
| Constructor Detail |
|---|
public DefaultItemSorter()
Comparator
for comparing Propertyvalues.
public DefaultItemSorter(Comparator<Object> propertyValueComparator)
Comparator
indicated by the propertyValueComparator parameter for
comparing Propertyvalues.
propertyValueComparator - The comparator to use when comparing individual
Property values| Method Detail |
|---|
public int compare(Object o1,
Object o2)
ItemSorter
The parameters for the ItemSorter compare()
method must always be item ids which exist in the container set using
#setSortProperties(Sortable, Object[], boolean[]).
compare in interface ItemSortercompare in interface Comparator<Object>Comparator.compare(Object, Object)
protected int compareProperty(Object propertyId,
boolean sortDirection,
Item item1,
Item item2)
propertyId in the items
indicated by item1 and item2 for order. Returns
a negative integer, zero, or a positive integer as the property value in
the first item is less than, equal to, or greater than the property value
in the second item. If the sortDirection is false the
returned value is negated.
The comparator set for this DefaultItemSorter is used for
comparing the two property values.
propertyId - The property id for the property that is used for comparison.sortDirection - The direction of the sort. A false value negates the result.item1 - The first item to compare.item2 - The second item to compare.
sortDirection is false.
public void setSortProperties(Container.Sortable container,
Object[] propertyId,
boolean[] ascending)
ItemSorterItemSorter
sorts the container.
setSortProperties in interface ItemSortercontainer - The container that will be sorted. The container must contain
the propertyIds given in the propertyId
parameter.propertyId - The property ids used for sorting. The property ids must exist
in the container and should only be used if they are also
sortable, i.e include in the collection returned by
container.getSortableContainerPropertyIds(). See
Container.Sortable.sort(Object[], boolean[]) for more
information.ascending - Sorting order flags for each property id. See
Container.Sortable.sort(Object[], boolean[]) for more
information.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||