src/share/classes/javax/swing/DefaultRowSorter.java
Print this page
@@ -126,11 +126,11 @@
private int[] modelToView;
/**
* Comparators specified by column.
*/
- private Comparator[] comparators;
+ private Comparator<?>[] comparators;
/**
* Whether or not the specified column is sortable, by column.
*/
private boolean[] isSortable;
@@ -141,11 +141,11 @@
private SortKey[] cachedSortKeys;
/**
* Cached comparators for the current sort
*/
- private Comparator[] sortComparators;
+ private Comparator<?>[] sortComparators;
/**
* Developer supplied Filter.
*/
private RowFilter<? super M,? super I> filter;
@@ -693,11 +693,11 @@
/**
* Caches the sort keys before a sort.
*/
private void cacheSortKeys(List<? extends SortKey> keys) {
int keySize = keys.size();
- sortComparators = new Comparator[keySize];
+ sortComparators = new Comparator<?>[keySize];
for (int i = 0; i < keySize; i++) {
sortComparators[i] = getComparator0(keys.get(i).getColumn());
}
cachedSortKeys = keys.toArray(new SortKey[keySize]);
}
@@ -758,11 +758,11 @@
* the range of the underlying model
*/
public void setComparator(int column, Comparator<?> comparator) {
checkColumn(column);
if (comparators == null) {
- comparators = new Comparator[getModelWrapper().getColumnCount()];
+ comparators = new Comparator<?>[getModelWrapper().getColumnCount()];
}
comparators[column] = comparator;
}
/**
@@ -784,12 +784,12 @@
return null;
}
// Returns the Comparator to use during sorting. Where as
// getComparator() may return null, this will never return null.
- private Comparator getComparator0(int column) {
- Comparator comparator = getComparator(column);
+ private Comparator<?> getComparator0(int column) {
+ Comparator<?> comparator = getComparator(column);
if (comparator != null) {
return comparator;
}
// This should be ok as useToString(column) should have returned
// true in this case.
@@ -963,11 +963,13 @@
result = -1;
}
} else if (v2 == null) {
result = 1;
} else {
- result = sortComparators[counter].compare(v1, v2);
+ Comparator<Object> c =
+ (Comparator<Object>)sortComparators[counter];
+ result = c.compare(v1, v2);
}
if (sortOrder == SortOrder.DESCENDING) {
result *= -1;
}
}
@@ -1362,14 +1364,14 @@
* Row is used to handle the actual sorting by way of Comparable. It
* will use the sortKeys to do the actual comparison.
*/
// NOTE: this class is static so that it can be placed in an array
private static class Row implements Comparable<Row> {
- private DefaultRowSorter sorter;
+ private DefaultRowSorter<?, ?> sorter;
int modelIndex;
- public Row(DefaultRowSorter sorter, int index) {
+ public Row(DefaultRowSorter<?, ?> sorter, int index) {
this.sorter = sorter;
modelIndex = index;
}
public int compareTo(Row o) {