com.arsdigita.bebop.table
Interface TableModel

All Known Implementing Classes:
DataTable.DataQueryTableModel, GridTableModel

public interface TableModel

The TableModel is the abstraction a Table uses to access the data it displays. The table will ask its TableModelBuilder to instantiate a new table model once for each request it processes.

The table will request each element in the model at most once per request, moving through the rows with successive calls to nextRow(). For each row, the table retrieves the values and keys in each column with calls to getElementAt(int) and getKeyAt(int).

The table data is accessed by the table by moving through the rows of the table model with calls to nextRow(). The data for each column in a row is represented by two objects: the data element which usually contains display information for that column and can be as simple as a string, and the key, which is used to identify the column. The key is usually a suitable representation of the primary key of the underlying object in the database. The key needs to be unique amongst all rows in the table model, but doesn't need to uniquely identify the row and column for that data item - all calls to getKeyAt(int) can return the same value for one row in the table model.

Version:
$Id: //core-platform/dev/src/com/arsdigita/bebop/table/TableModel.java#7 $
Author:
David Lutterkort
See Also:
Table, TableModelBuilder

Field Summary
static String versionId
           
 
Method Summary
 int getColumnCount()
          Return the number of columns this table model has.
 Object getElementAt(int columnIndex)
          Return the data element for the given column and the current row.
 Object getKeyAt(int columnIndex)
          Return the key for the given column and the current row.
 boolean nextRow()
          Move to the next row and return true if the model is now positioned on a valid row.
 

Field Detail

versionId

public static final String versionId
See Also:
Constant Field Values
Method Detail

getColumnCount

public int getColumnCount()
Return the number of columns this table model has.

Returns:
the number of columns in the table model

nextRow

public boolean nextRow()
Move to the next row and return true if the model is now positioned on a valid row. Initially, the table model is positioned before the first row. The table will call this method before it retrieves the data for the row with calls to getElementAt and getKeyAt.

If this method returns true, subsequent calls to getElementAt and getKeyAt have to succeed and return non-null objects. If this method returns false, the table assumes that it has traversed all the data contained in this model.

Returns:
true if the model is positioned on a valid row

getElementAt

public Object getElementAt(int columnIndex)
Return the data element for the given column and the current row. The returned object will be passed to the table cell renderer as the value argument without modifications.

Parameters:
columnIndex - the number of the column for which to get data
Returns:
the object to pass to the table cell renderer for display
See Also:
TableCellRenderer

getKeyAt

public Object getKeyAt(int columnIndex)
Return the key for the given column and the current row. The key has to be unique for each row in the table model, but does not need to be unique for each row and column, though it may. The key is passed to the table cell renderer as the key argument.

Parameters:
columnIndex - the number of the column for which to get data
Returns:
the key for the given column and the current row.
See Also:
TableCellRenderer


Copyright (c) 2004 Red Hat, Inc. Corporation. All Rights Reserved. Generated at July 21 2004:2337 UTC