com.sun.faban.common
Class SortableTableModel

java.lang.Object
  extended by com.sun.faban.common.TableModel
      extended by com.sun.faban.common.SortableTableModel

public class SortableTableModel
extends TableModel

The TableModel represents a generic model for the LiveGrid data table AJAX component. It can be used to represent almost any data in a table form.

Author:
Akara Sucharitakul

Constructor Summary
SortableTableModel(int columns)
          Constructs a TableModel.
SortableTableModel(int columns, int rowInitCapacity)
          Constructs a TableModel.
 
Method Summary
 int getSortColumn()
          Obtains the column index the TableModel is currently sorted by.
 SortDirection getSortDirection()
          Obtains the direction the TableModel is currently sorted.
 void sort(int column, SortDirection direction)
          Sorts the TableModel according to the column index and direction.
 void sort(String columnName, SortDirection direction)
          Sorts the TableModel according to the column and direction.
 
Methods inherited from class com.sun.faban.common.TableModel
columns, getField, getHeader, getHeaders, getRow, newRow, rows, setHeader
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SortableTableModel

public SortableTableModel(int columns)
Constructs a TableModel.

Parameters:
columns - The number of columns in the table

SortableTableModel

public SortableTableModel(int columns,
                          int rowInitCapacity)
Constructs a TableModel.

Parameters:
columns - The number of columns in the table
rowInitCapacity - The initial row capacity of the table
Method Detail

sort

public void sort(String columnName,
                 SortDirection direction)
Sorts the TableModel according to the column and direction.

Parameters:
columnName - The name of the column matching the header
direction - The direction of the sort

sort

public void sort(int column,
                 SortDirection direction)
Sorts the TableModel according to the column index and direction.

Parameters:
column - The index of the column to sort by
direction - The direction of the sort

getSortColumn

public int getSortColumn()
Obtains the column index the TableModel is currently sorted by.

Returns:
The column index, or -1 if the model is not sorted.

getSortDirection

public SortDirection getSortDirection()
Obtains the direction the TableModel is currently sorted. If the model is not sorted, this method's return value is undefined.

Returns:
The direction the table is currently sorted