Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| WebLogic Integration
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.bea.wlpi.client.common
Class SortableTableModel

    java.lang.Object
      |
      +--javax.swing.table.AbstractTableModel
            |
            +--com.bea.wlpi.client.common.MappedTableModel
                  |
                  +--com.bea.wlpi.client.common.SortableTableModel

public final class SortableTableModel
extends MappedTableModel

A sorter for `TableModel`s. The sorter has a backing model (conforming to `TableModel`) and implements `TableModel`. `SortableTableModel` does not store or copy the data in the `TableModel`, instead it maintains a parallel array of integer indexes into the underlying table model. The sorter registers itself with the underlying model as a `TableModelListener` and responds to changes in the model by adjusting or reallocating its index array. As requests are made of the sorter (like `getValueAt(row, col)` it redirects them to its model via the mapping array. That way the `SortableTableModel` appears to hold another copy of the table with the rows in a different order. The sorter uses a stable algorithm, which means that it does not move rows around when its comparison function returns 0 to denote that they are equivalent.

Author:
  Copyright © 2000, 2001 BEA Systems, Inc. All Rights Reserved.
See Also:
  Serialized Form

Field Summary
`static boolean` | `debug`

Fields inherited from class com.bea.wlpi.client.common.MappedTableModel
`model`

Fields inherited from class javax.swing.table.AbstractTableModel
`listenerList`

Constructor Summary
`SortableTableModel()` Create a new `SortableTableModel` with no backing model.
`SortableTableModel(javax.swing.table.TableModel model)` Create a new `SortableTableModel` with the specified backing model.

Method Summary
`int` | `getMappedRow(int row)` Return a mapped row number.
`int` | `getSortIndex()` Return the current sort column index.
`java.lang.Object` | `getValueAt(int row, int col)` Return a table cell value.
`boolean` | `isSortAscending()` Check whether sort order is ascending or descending.
`void` | `load(java.util.Properties prop, java.lang.String prefix)` Retrieve the sort column index and sort order from a `Properties` object.
`void` | `setModel(javax.swing.table.TableModel model)` Set the backing model.
`void` | `setValueAt(java.lang.Object value, int row, int col)` Set a table cell value.
`void` | `sort()` Re-sort the table using the previously specified column and order.
`void` | `sort(int col)` Sort the table on the specified column in ascending order.
`void` | `sort(int col, boolean ascending)` Sort the table on the specified column in the specified order.
`void` | `store(java.util.Properties prop, java.lang.String prefix)` Store the sort column index and sort order.
`void` | `tableChanged(javax.swing.event.TableModelEvent e)` Respond to a "table changed" notification event.

Methods inherited from class com.bea.wlpi.client.common.MappedTableModel
`getColumnClass, getColumnCount, getColumnName, getModel, getRowCount, isCellEditable`

Methods inherited from class javax.swing.table.AbstractTableModel
`addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, removeTableModelListener`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### debug

    public static boolean debug

Constructor Detail

### SortableTableModel

    public SortableTableModel()

  Create a new `SortableTableModel` with no backing model.

### SortableTableModel

    public SortableTableModel(javax.swing.table.TableModel model)

  Create a new `SortableTableModel` with the specified backing model. (The backing model supplies the actual data.)

  Parameters:
    `model` - The backing table model.

Method Detail

### setModel

    public void setModel(javax.swing.table.TableModel model)

  Set the backing model. (The backing model supplies the actual data.)

  Parameters:
    `model` - The backing table model.
  Overrides:
    setModel in class MappedTableModel

### sort

    public void sort()

  Re-sort the table using the previously specified column and order. If the table is currently unsorted, the method has no effect.

  See Also:
    `sort(int)`, `sort(int, boolean)`

### sort

    public void sort(int col)

  Sort the table on the specified column in ascending order.

  Parameters:
    `col` - The column number on which to sort.
  See Also:
    `sort()`, `sort(int, boolean)`

### sort

    public void sort(int col,
                     boolean ascending)

  Sort the table on the specified column in the specified order. The implementation achieves this by sorting the array of mapping indexes, which are initially set to the identity mapping (i.e. indexes[i] = i for 0 <= i < indexes.length). If `col == -1`, the mapping reverts to the identity mapping.

  Parameters:
    `col` - The column number on which to sort.
    `ascending` -
  See Also:
    `sort()`, `sort(int)`

### getMappedRow

    public int getMappedRow(int row)

  Return a mapped row number.

  Parameters:
    `row` - The logical row number in the JTable.
  Returns:
    The physical row number in the backing model.

### getSortIndex

    public int getSortIndex()

  Return the current sort column index.

  Returns:
    The index of the current sort column, or `-1` if unsorted.

### isSortAscending

    public boolean isSortAscending()

  Check whether sort order is ascending or descending.

  Returns:
    `true` for ascending sort order.

### store

    public void store(java.util.Properties prop,
                      java.lang.String prefix)

  Store the sort column index and sort order.

  Parameters:
    `prop` - A `Properties` object in which to store values.
    `prefix` - String with which to prefix the entries (caller must avoid namespace conflicts).
  See Also:
    `load(java.util.Properties, java.lang.String)`

### load

    public void load(java.util.Properties prop,
                     java.lang.String prefix)

  Retrieve the sort column index and sort order from a `Properties` object. It is assumed that the `Properties` object contains value from a prior call to `store`.

  Parameters:
    `prop` - Properties object in which to store values.
    `prefix` - String with which to prefix the entries (caller must avoid namespace conflicts).
  See Also:
    `store(java.util.Properties, java.lang.String)`

### getValueAt

    public java.lang.Object getValueAt(int row,
                                       int col)

  Return a table cell value.

  Parameters:
    `row` - The logical row number.
    `col` - The logical column number.
  Returns:
    The value in the specified table cell.
  Overrides:
    getValueAt in class MappedTableModel

### setValueAt

    public void setValueAt(java.lang.Object value,
                           int row,
                           int col)

  Set a table cell value.

  Parameters:
    `value` - The value to set.
    `row` - The logical row number.
    `col` - The logical column number.
  Overrides:
    setValueAt in class MappedTableModel

### tableChanged

    public void tableChanged(javax.swing.event.TableModelEvent e)

  Respond to a "table changed" notification event.

  Parameters:
    `e` - The notification event.
  Overrides:
    tableChanged in class MappedTableModel

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| WebLogic Integration
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

WebLogic Integration (WLI)