src/share/classes/javax/swing/DefaultRowSorter.java

Print this page

        

*** 126,136 **** private int[] modelToView; /** * Comparators specified by column. */ ! private Comparator[] comparators; /** * Whether or not the specified column is sortable, by column. */ private boolean[] isSortable; --- 126,136 ---- private int[] modelToView; /** * Comparators specified by column. */ ! private Comparator<?>[] comparators; /** * Whether or not the specified column is sortable, by column. */ private boolean[] isSortable;
*** 141,151 **** private SortKey[] cachedSortKeys; /** * Cached comparators for the current sort */ ! private Comparator[] sortComparators; /** * Developer supplied Filter. */ private RowFilter<? super M,? super I> filter; --- 141,151 ---- private SortKey[] cachedSortKeys; /** * Cached comparators for the current sort */ ! private Comparator<?>[] sortComparators; /** * Developer supplied Filter. */ private RowFilter<? super M,? super I> filter;
*** 693,703 **** /** * Caches the sort keys before a sort. */ private void cacheSortKeys(List<? extends SortKey> keys) { int keySize = keys.size(); ! sortComparators = new Comparator[keySize]; for (int i = 0; i < keySize; i++) { sortComparators[i] = getComparator0(keys.get(i).getColumn()); } cachedSortKeys = keys.toArray(new SortKey[keySize]); } --- 693,703 ---- /** * Caches the sort keys before a sort. */ private void cacheSortKeys(List<? extends SortKey> keys) { int keySize = keys.size(); ! 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,768 **** * the range of the underlying model */ public void setComparator(int column, Comparator<?> comparator) { checkColumn(column); if (comparators == null) { ! comparators = new Comparator[getModelWrapper().getColumnCount()]; } comparators[column] = comparator; } /** --- 758,768 ---- * the range of the underlying model */ public void setComparator(int column, Comparator<?> comparator) { checkColumn(column); if (comparators == null) { ! comparators = new Comparator<?>[getModelWrapper().getColumnCount()]; } comparators[column] = comparator; } /**
*** 784,795 **** 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); if (comparator != null) { return comparator; } // This should be ok as useToString(column) should have returned // true in this case. --- 784,795 ---- 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); if (comparator != null) { return comparator; } // This should be ok as useToString(column) should have returned // true in this case.
*** 963,973 **** result = -1; } } else if (v2 == null) { result = 1; } else { ! result = sortComparators[counter].compare(v1, v2); } if (sortOrder == SortOrder.DESCENDING) { result *= -1; } } --- 963,975 ---- result = -1; } } else if (v2 == null) { result = 1; } else { ! Comparator<Object> c = ! (Comparator<Object>)sortComparators[counter]; ! result = c.compare(v1, v2); } if (sortOrder == SortOrder.DESCENDING) { result *= -1; } }
*** 1362,1375 **** * 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; int modelIndex; ! public Row(DefaultRowSorter sorter, int index) { this.sorter = sorter; modelIndex = index; } public int compareTo(Row o) { --- 1364,1377 ---- * 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; int modelIndex; ! public Row(DefaultRowSorter<?, ?> sorter, int index) { this.sorter = sorter; modelIndex = index; } public int compareTo(Row o) {