voji.ui
Class JResultTable.ResultTableModel

java.lang.Object
  |
  +--javax.swing.table.AbstractTableModel
        |
        +--voji.ui.JResultTable.ResultTableModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.table.TableModel
Enclosing class:
JResultTable

protected class JResultTable.ResultTableModel
extends javax.swing.table.AbstractTableModel

This is the table model for ResultTables

See Also:
Serialized Form

Field Summary
protected  java.lang.Object[][] data
          The internal data
protected  java.util.Vector formats
          The formats of the columns
protected  int maxRows
          The maximum number of rows
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
JResultTable.ResultTableModel()
          Constructs a ResultTableModel with empty data
 
Method Summary
 void addFormat(DataFormat format)
          Adds a new format
 int getColumnCount()
           
 int getID(int row)
          Returns the ID of the specified row
 int getRow(int id)
          Looks for the row with the specified ID
 int getRowCount()
           
 java.lang.Object getValueAt(int row, int column)
           
 void setData(java.sql.ResultSet resultSet)
          Sets the data of this model.
 void setMaxRows(int maxRows)
          Sets the maximum number of rows accepted by setData().
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getColumnName, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

maxRows

protected int maxRows
The maximum number of rows


formats

protected java.util.Vector formats
The formats of the columns


data

protected java.lang.Object[][] data
The internal data

Constructor Detail

JResultTable.ResultTableModel

public JResultTable.ResultTableModel()
Constructs a ResultTableModel with empty data

Method Detail

getRowCount

public int getRowCount()
Returns:
the number of rows

getColumnCount

public int getColumnCount()
Returns:
the number of columns

getValueAt

public java.lang.Object getValueAt(int row,
                                   int column)
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
the Object at the specified cell

getID

public int getID(int row)
Returns the ID of the specified row

Parameters:
row - the index of the row
Returns:
the ID of the given row or -1 if the row index is invalid or the row got an invalid ID with the last setData().

getRow

public int getRow(int id)
Looks for the row with the specified ID

Parameters:
id - the ID of the row
Returns:
the index of the given row or -1 if the row index is invalid or the row got an invalid ID with the last setData().

setMaxRows

public void setMaxRows(int maxRows)
Sets the maximum number of rows accepted by setData().

Parameters:
maxRows - the maximum number of rows or -1 for no maximum

addFormat

public void addFormat(DataFormat format)
Adds a new format

Parameters:
format - the DataFormat to use for the next column

setData

public void setData(java.sql.ResultSet resultSet)
             throws java.sql.SQLException
Sets the data of this model. It's retrieved from the given ResultSet where the first field is interpreted as the ID and not shown. The other fields are shown in the same order as in the given ResultSet.

Parameters:
resultSet - the ResultSet where to take the data from
Throws:
java.sql.SQLException - if there is an SQLException while working with resultSet