|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.data.provider.impl.BasicTableDataSorter
public class BasicTableDataSorter
The BasicTableDataSorter utilizes the Comparable interface on
data objects in the specified TableDataProvider to provide a
sorted version of the data based on the specified sort criteria.
| Field Summary | |
|---|---|
protected SortCriteria[] |
sortCriteria
Storage for the sort criteria |
protected java.util.Locale |
sortLocale
Storage for the sort locale |
| Constructor Summary | |
|---|---|
BasicTableDataSorter()
Constructs a BasicTableDataSorter with no sort criteria or locale setting. |
|
BasicTableDataSorter(java.util.Locale sortLocale)
Constructs a BasicTableDataSorter with the specified locale with no initial sort criteria. |
|
BasicTableDataSorter(SortCriteria[] sortCriteria)
Constructs a BasicTableDataSorter with the specified initial sort criteria and no locale setting. |
|
BasicTableDataSorter(SortCriteria[] sortCriteria,
java.util.Locale sortLocale)
Constructs a BasicTableDataSorter with the specified initial sort criteria and sort locale. |
|
| Method Summary | |
|---|---|
SortCriteria[] |
getSortCriteria()
Returns the current sort criteria on this data sorter. |
java.util.Locale |
getSortLocale()
Gets the sort locale used when comparing objects. |
void |
setSortCriteria(SortCriteria[] sortCriteria)
Sets the sort criteria on this data sorter. |
void |
setSortLocale(java.util.Locale sortLocale)
Sets the sort locale to use when comparing objects. |
RowKey[] |
sort(TableDataProvider provider,
RowKey[] rows)
Get an array containing an row of sorted rows. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected SortCriteria[] sortCriteria
protected java.util.Locale sortLocale
| Constructor Detail |
|---|
public BasicTableDataSorter()
public BasicTableDataSorter(SortCriteria[] sortCriteria)
sortCriteria - The desired initial sort criteriapublic BasicTableDataSorter(java.util.Locale sortLocale)
sortLocale - The desired sort locale
public BasicTableDataSorter(SortCriteria[] sortCriteria,
java.util.Locale sortLocale)
sortCriteria - The desired initial sort criteriasortLocale - The desired sort locale| Method Detail |
|---|
public void setSortCriteria(SortCriteria[] sortCriteria)
Sets the sort criteria on this data sorter.
setSortCriteria in interface TableDataSortersortCriteria - An array of SortCriteria objects defining
the sort order on this TableDataSorterpublic SortCriteria[] getSortCriteria()
Returns the current sort criteria on this data sorter.
getSortCriteria in interface TableDataSorterpublic void setSortLocale(java.util.Locale sortLocale)
Sets the sort locale to use when comparing objects. If none is set,
the default locale should be used via Locale.getDefault().
setSortLocale in interface TableDataSortersortLocale - The desired Locale to use for sort comparisonspublic java.util.Locale getSortLocale()
Gets the sort locale used when comparing objects. If none is set,
the default locale should be used via Locale.getDefault().
getSortLocale in interface TableDataSorter
public RowKey[] sort(TableDataProvider provider,
RowKey[] rows)
throws DataProviderException
Get an array containing an row of sorted rows. This method does not modify the model, but creates an rowed array of sorted rows. The returned array is typically used to row through model rows to obtain the next sorted object.
The sorting algorithms selected for this method are based on the merge sort and radix sort. The radix sort, always sorts on the least significant object. For example, we could sort information three times with a stable sort: first on day, next on month, and finally on year. The analysis of the running time depends on the stable sort used as the intermediate sorting algorithm. If there are m passes, and m is constant, the radix sort runs in linear time. The total time for the merge sort algorithm is O(n log n) in the worst case.
Sorts the rows from the specified TableDataProvider based on
the current sort criteria, and returns an array of RowKeys
representing the sorted row order. Any excluded rows from the return
value of sort(...) should be considered unsortable, and thus
should be displayed at the end of whatever UI is presenting these items.
NOTE: If a component is bound to a TableDataProvider and
an TableDataSorter, which are the *same* instance, this method is never
called. The sort order is assumed to be intrinsic in the row key order
of the TableDataProvider, based on the currently set sort
criteria.
sort in interface TableDataSorterprovider - The TableDataProvider to sortrows - The array of RowKeys to sort. If this is
null then the return value should be
null or an empty array of RowKeys.
RowKeys representing the sorted rows from
the specified TableDataProvider. Any excluded rows
from the return value of this method should be considered
unsortable, and thus should be displayed at the end of whatever
UI is presenting these items. null may be returned
to indicate that sorting is not possible.
DataProviderException - Implementations may wish to surface
internal exceptions (nested in DataProviderException) rather
than simply returning null or an empty array. A DPE may also
indicate that the passed TableDataProvider or RowKeys are not
valid. Consult the documentation of the specific TableDataSorter
implementation for details on what exceptions might be wrapped by
a DPE.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||