nextapp.echo.table
Class AbstractTableModel

java.lang.Object
  extended by nextapp.echo.table.AbstractTableModel
All Implemented Interfaces:
java.io.Serializable, TableModel
Direct Known Subclasses:
BoundTableModel, DefaultTableModel, TableModelAdapter

public abstract class AbstractTableModel
extends java.lang.Object
implements java.io.Serializable, TableModel

An abstract implementation of a table model. This class provides listener management and convenience methods for notifying listeners of events. It provides generic implementations of getColumnClass() (which always returns Object.class) and getColumnName() (which returns "spreadsheet-style" column names). It also provides an empty implementation of setValueAt().

This class should be extended when you desire to create a TableModel which is best served by a custom representation of its internal data.

See Also:
DefaultTableModel, Serialized Form

Field Summary
protected  EventListenerList listenerList
          A listener management facility.
 
Constructor Summary
AbstractTableModel()
          Default constructor.
 
Method Summary
 void addTableModelListener(TableModelListener l)
          Adds a listener that will be notified of changes to the table model.
 void fireTableCellUpdated(int column, int row)
          Notifies listeners that the contents of the cell at the specified coordinate were changed.
 void fireTableChanged(TableModelEvent e)
          Notifies all TableModelListeners of the specified event.
 void fireTableDataChanged()
          Notifies listeners that the content of the table (possibly including the number of rows) was changed, but that the table's structure has remained intact.
 void fireTableRowsDeleted(int firstRow, int lastRow)
          Notifies listeners that rows the rows from firstRow to LastRow were deleted.
 void fireTableRowsInserted(int firstRow, int lastRow)
          Notifies listeners that rows the rows from firstRow to LastRow were inserted.
 void fireTableRowsUpdated(int firstRow, int lastRow)
          Notifies listeners that data found in the specified rows was updated.
 void fireTableStructureChanged()
          Notifies all listeners that all data in the table may have changed, including the size and structure of the table.
 java.lang.Class getColumnClass(int column)
          Returns Object.class.
 java.lang.String getColumnName(int column)
          Returns the value found at the given coordinate within the table.
 boolean isRowEditable(int row)
           When a table model supports editing of data, this method will be called to query if a row is currently editable.
 void removeTableModelListener(TableModelListener l)
          Removes a listener from being notified of changes to the table model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface nextapp.echo.table.TableModel
getColumnCount, getRowCount, getValueAt
 

Field Detail

listenerList

protected EventListenerList listenerList
A listener management facility.

Constructor Detail

AbstractTableModel

public AbstractTableModel()
Default constructor.

Method Detail

addTableModelListener

public void addTableModelListener(TableModelListener l)
Adds a listener that will be notified of changes to the table model.

Specified by:
addTableModelListener in interface TableModel
Parameters:
l - The listener to add.

fireTableCellUpdated

public void fireTableCellUpdated(int column,
                                 int row)
Notifies listeners that the contents of the cell at the specified coordinate were changed.

Parameters:
column - The column value of the cell that changed.
row - The row value of the cell that changed.

fireTableDataChanged

public void fireTableDataChanged()
Notifies listeners that the content of the table (possibly including the number of rows) was changed, but that the table's structure has remained intact.


fireTableRowsDeleted

public void fireTableRowsDeleted(int firstRow,
                                 int lastRow)
Notifies listeners that rows the rows from firstRow to LastRow were deleted.

Parameters:
firstRow - The first row that was deleted.
lastRow - The last row that was deleted.

fireTableRowsInserted

public void fireTableRowsInserted(int firstRow,
                                  int lastRow)
Notifies listeners that rows the rows from firstRow to LastRow were inserted.

Parameters:
firstRow - The first row of the new inserted rows.
lastRow - The last row of the new inserted rows.

fireTableRowsUpdated

public void fireTableRowsUpdated(int firstRow,
                                 int lastRow)
Notifies listeners that data found in the specified rows was updated.

Parameters:
firstRow - The first row that was updated.
lastRow - The last row that was updated.

fireTableStructureChanged

public void fireTableStructureChanged()
Notifies all listeners that all data in the table may have changed, including the size and structure of the table.


fireTableChanged

public void fireTableChanged(TableModelEvent e)
Notifies all TableModelListeners of the specified event.

Parameters:
e - The event to send to the listeners.

getColumnClass

public java.lang.Class getColumnClass(int column)
Returns Object.class.

Specified by:
getColumnClass in interface TableModel
Parameters:
column - The column number whose class is to be returned.
Returns:
The most-specific class found in the given table column.

getColumnName

public java.lang.String getColumnName(int column)
Returns the value found at the given coordinate within the table. This method returns a column name using the same notation as a spreadsheet (A, B, C ... Y, Z, AA, AB, AC ...)

Specified by:
getColumnName in interface TableModel
Parameters:
column - The column of the value to return.
Returns:
The name of the specified column number.

removeTableModelListener

public void removeTableModelListener(TableModelListener l)
Removes a listener from being notified of changes to the table model.

Specified by:
removeTableModelListener in interface TableModel
Parameters:
l - The listener to remove.

isRowEditable

public boolean isRowEditable(int row)
Description copied from interface: TableModel

When a table model supports editing of data, this method will be called to query if a row is currently editable.

Specified by:
isRowEditable in interface TableModel