org.apache.jorphan.gui

## Class ObjectTableSorter

- java.lang.Object
- - javax.swing.RowSorter<ObjectTableModel>
  - - org.apache.jorphan.gui.ObjectTableSorter

-     public class ObjectTableSorter
      extends javax.swing.RowSorter<ObjectTableModel>

  Implementation of a `RowSorter` for `ObjectTableModel`
  Since:
    3.2

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `protected class` | `ObjectTableSorter.PreserveLastRowComparator`
    `class` | `ObjectTableSorter.Row` View row with model mapping.

    - ### Nested classes/interfaces inherited from class javax.swing.RowSorter

      `javax.swing.RowSorter.SortKey`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ObjectTableSorter(ObjectTableModel model)`

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `allRowsChanged()`
    `int` | `convertRowIndexToModel(int index)`
    `int` | `convertRowIndexToView(int index)`
    `ObjectTableSorter` | `fixLastRow()` Sets `primary comparator` to one that don't sort last row.
    `protected java.util.Comparator<ObjectTableSorter.Row>` | `getComparatorFromSortKey(javax.swing.RowSorter.SortKey sortkey)`
    `protected java.util.Comparator<?>` | `getDefaultComparator(int column)` Builds a default comparator based on model column class.
    `java.util.Comparator<ObjectTableSorter.Row>` | `getFallbackComparator()`
    `ObjectTableModel` | `getModel()`
    `int` | `getModelRowCount()`
    `java.util.Comparator<ObjectTableSorter.Row>` | `getPrimaryComparator()`
    `java.util.List<? extends javax.swing.RowSorter.SortKey>` | `getSortKeys()`
    `java.util.Comparator<?>` | `getValueComparator(int column)`
    `int` | `getViewRowCount()`
    `protected void` | `invalidate()`
    `protected boolean` | `isSortable(int column)`
    `protected boolean` | `isSorted()`
    `protected boolean` | `isSorted(int column)`
    `void` | `modelStructureChanged()`
    `protected void` | `rowsChanged(int firstRow, int endRow, boolean deleted, boolean inserted)`
    `void` | `rowsDeleted(int firstRow, int endRow)`
    `void` | `rowsInserted(int firstRow, int endRow)`
    `void` | `rowsUpdated(int firstRow, int endRow)`
    `void` | `rowsUpdated(int firstRow, int endRow, int column)`
    `ObjectTableSorter` | `setFallbackComparator(java.util.Comparator<ObjectTableSorter.Row> comparator)` Sets a fallback comparator (defaults to model index comparison) if none `primary`, neither `column value comparators` can make differences between two rows.
    `ObjectTableSorter` | `setPrimaryComparator(java.util.Comparator<ObjectTableSorter.Row> primaryComparator)` Comparator used prior to sorted columns.
    `void` | `setSortKey(javax.swing.RowSorter.SortKey sortkey)`
    `void` | `setSortKeys(java.util.List<? extends javax.swing.RowSorter.SortKey> keys)`
    `ObjectTableSorter` | `setValueComparator(int column, java.util.Comparator<?> comparator)` Assign comparator to given column, if `null` a getDefaultComparator(int) default one is used instead.
    `protected void` | `sort()` Sort table
    `void` | `toggleSortOrder(int column)`
    `protected void` | `updateModelToView()` fill in modelToView list with index of view
    `protected void` | `validate()`

    - ### Methods inherited from class javax.swing.RowSorter

      `addRowSorterListener, fireRowSorterChanged, fireSortOrderChanged, removeRowSorterListener`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ObjectTableSorter

          public ObjectTableSorter(ObjectTableModel model)

  - ### Method Detail

    - #### getPrimaryComparator

          public java.util.Comparator<ObjectTableSorter.Row> getPrimaryComparator()

      Returns:
        Comparator used prior to sorted columns.

    - #### getValueComparator

          public java.util.Comparator<?> getValueComparator(int column)

      Parameters:
        `column` - to be compared
      Returns:
        Comparator used on column.

    - #### getFallbackComparator

          public java.util.Comparator<ObjectTableSorter.Row> getFallbackComparator()

      Returns:
        Comparator if all sorted columns matches. Defaults to model index comparison.

    - #### setPrimaryComparator

          public ObjectTableSorter setPrimaryComparator(java.util.Comparator<ObjectTableSorter.Row> primaryComparator)

      Comparator used prior to sorted columns.
      Parameters:
        `primaryComparator` - `Comparator` to be used first
      Returns:
        `this`

    - #### fixLastRow

          public ObjectTableSorter fixLastRow()

      Sets `primary comparator` to one that don't sort last row.
      Returns:
        `this`

    - #### setValueComparator

          public ObjectTableSorter setValueComparator(int column,
                                                      java.util.Comparator<?> comparator)

      Assign comparator to given column, if `null` a getDefaultComparator(int) default one is used instead.
      Parameters:
        `column` - Model column index.
        `comparator` - Column value comparator.
      Returns:
        `this`

    - #### getDefaultComparator

          protected java.util.Comparator<?> getDefaultComparator(int column)

      Builds a default comparator based on model column class. `Collator.getInstance()` for `String`, `natural order` for `Comparable`, no sort support for others.
      Parameters:
        `column` - Model column index.
      Returns:
        default `Comparator`

    - #### setFallbackComparator

          public ObjectTableSorter setFallbackComparator(java.util.Comparator<ObjectTableSorter.Row> comparator)

      Sets a fallback comparator (defaults to model index comparison) if none `primary`, neither `column value comparators` can make differences between two rows.
      Parameters:
        `comparator` - to be used, when all other `Comparator`s can't see a difference
      Returns:
        `this`

    - #### getModel

          public ObjectTableModel getModel()

      Specified by:
        `getModel` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### toggleSortOrder

          public void toggleSortOrder(int column)

      Specified by:
        `toggleSortOrder` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### convertRowIndexToModel

          public int convertRowIndexToModel(int index)

      Specified by:
        `convertRowIndexToModel` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### convertRowIndexToView

          public int convertRowIndexToView(int index)

      Specified by:
        `convertRowIndexToView` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### setSortKeys

          public void setSortKeys(java.util.List<? extends javax.swing.RowSorter.SortKey> keys)

      Specified by:
        `setSortKeys` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### setSortKey

          public void setSortKey(javax.swing.RowSorter.SortKey sortkey)

    - #### getSortKeys

          public java.util.List<? extends javax.swing.RowSorter.SortKey> getSortKeys()

      Specified by:
        `getSortKeys` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### getViewRowCount

          public int getViewRowCount()

      Specified by:
        `getViewRowCount` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### getModelRowCount

          public int getModelRowCount()

      Specified by:
        `getModelRowCount` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### modelStructureChanged

          public void modelStructureChanged()

      Specified by:
        `modelStructureChanged` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### allRowsChanged

          public void allRowsChanged()

      Specified by:
        `allRowsChanged` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### rowsInserted

          public void rowsInserted(int firstRow,
                                   int endRow)

      Specified by:
        `rowsInserted` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### rowsDeleted

          public void rowsDeleted(int firstRow,
                                  int endRow)

      Specified by:
        `rowsDeleted` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### rowsUpdated

          public void rowsUpdated(int firstRow,
                                  int endRow)

      Specified by:
        `rowsUpdated` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### rowsChanged

          protected void rowsChanged(int firstRow,
                                     int endRow,
                                     boolean deleted,
                                     boolean inserted)

    - #### rowsUpdated

          public void rowsUpdated(int firstRow,
                                  int endRow,
                                  int column)

      Specified by:
        `rowsUpdated` in class `javax.swing.RowSorter<ObjectTableModel>`

    - #### isSortable

          protected boolean isSortable(int column)

    - #### isSorted

          protected boolean isSorted(int column)

    - #### isSorted

          protected boolean isSorted()

    - #### invalidate

          protected void invalidate()

    - #### validate

          protected void validate()

    - #### getComparatorFromSortKey

          protected java.util.Comparator<ObjectTableSorter.Row> getComparatorFromSortKey(javax.swing.RowSorter.SortKey sortkey)

    - #### sort

          protected void sort()

      Sort table

    - #### updateModelToView

          protected void updateModelToView()

      fill in modelToView list with index of view

Copyright © 1998-2018 Apache Software Foundation. All Rights Reserved.