Package adams.gui.core
Class ResultSetTableModel
- java.lang.Object
-
- javax.swing.table.AbstractTableModel
-
- adams.gui.core.AbstractBaseTableModel
-
- adams.gui.core.ResultSetTableModel
-
- All Implemented Interfaces:
LoggingLevelHandler,LoggingSupporter,SpreadSheetSupporter,Serializable,TableModel
public class ResultSetTableModel extends AbstractBaseTableModel
Table model for displaying an SQL ResultSet.- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
ResultSet, Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Hashtable<String,Integer>m_ColumnIndexfor fast access to the column names (name - index).protected String[]m_Columnsthe column titles.protected List<Object[]>m_Data-
Fields inherited from class adams.gui.core.AbstractBaseTableModel
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
-
-
Constructor Summary
Constructors Constructor Description ResultSetTableModel(String[] columns)Initializes an empty model.ResultSetTableModel(ResultSet rs)Initializes the model with the given result set.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetColumnCount()Returns the number of columns in the model.intgetColumnIndex(String columnName)Returns the column index associated with the column name.StringgetColumnName(int columnIndex)Returns the name of the column atcolumnIndex.intgetRowCount()Returns the number of rows in the model.ObjectgetValueAt(int rowIndex, int columnIndex)Returns the value for the cell atcolumnIndexandrowIndex.ObjectgetValueAt(int rowIndex, String columnName)Returns the value for the cell rowrowIndexand from the column namedcolumnName.protected voidinitialize()Initializes the members.-
Methods inherited from class adams.gui.core.AbstractBaseTableModel
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, setLoggingLevel, toSpreadSheet, toString
-
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getColumnClass, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt
-
-
-
-
Constructor Detail
-
ResultSetTableModel
public ResultSetTableModel(String[] columns)
Initializes an empty model.- Parameters:
columns- the column titles
-
ResultSetTableModel
public ResultSetTableModel(ResultSet rs) throws SQLException
Initializes the model with the given result set.- Parameters:
rs- the data to use- Throws:
SQLException- in case of an SQL error
-
-
Method Detail
-
initialize
protected void initialize()
Initializes the members.
-
getRowCount
public int getRowCount()
Returns the number of rows in the model.- Returns:
- the number of rows in the model
-
getColumnName
public String getColumnName(int columnIndex)
Returns the name of the column atcolumnIndex. This is used to initialize the table's column header name.- Specified by:
getColumnNamein interfaceTableModel- Overrides:
getColumnNamein classAbstractTableModel- Parameters:
columnIndex- the index of the column- Returns:
- the name of the column
-
getColumnCount
public int getColumnCount()
Returns the number of columns in the model.- Returns:
- the number of columns in the model
-
getValueAt
public Object getValueAt(int rowIndex, int columnIndex)
Returns the value for the cell atcolumnIndexandrowIndex.- Parameters:
rowIndex- the row whose value is to be queriedcolumnIndex- the column whose value is to be queried- Returns:
- the value Object at the specified cell
-
getColumnIndex
public int getColumnIndex(String columnName)
Returns the column index associated with the column name.- Parameters:
columnName- the name to look up- Returns:
- the index, -1 if not found
-
getValueAt
public Object getValueAt(int rowIndex, String columnName)
Returns the value for the cell rowrowIndexand from the column namedcolumnName.- Parameters:
rowIndex- the row whose value is to be queriedcolumnName- the name of the column whose value is to be queried- Returns:
- the value Object at the specified cell, null if not found or no value available
-
-