|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.swing.table.AbstractTableModel
com.citra.table.db.AbstractDatabaseTableModel
public abstract class AbstractDatabaseTableModel
AbstractDatabaseTableModel represents a sortable and filterable database model that is also cached. Sorting is provided via an internal SortTableModel instance, whereas filtering through an internal FilterTableModel instance. Finally, caching is handled by a TableCache object.
Field Summary | |
---|---|
protected TableCache |
cache
the cache |
protected FilterTableModel |
dbFilter
the internal filter tablemodel instance |
protected SortTableModel |
dbSorter
the internal sort tablemodel instance |
protected boolean |
rangedModel
true if the model is going to fetch data in ranges |
protected int |
rowCount
an index holding the last row count |
Fields inherited from class javax.swing.table.AbstractTableModel |
---|
listenerList |
Constructor Summary | |
---|---|
AbstractDatabaseTableModel(TableCache cache)
Constructs an AbstractDatabaseTableModel. |
Method Summary | |
---|---|
void |
fireTableChanged(TableModelEvent e)
Forwards the given notification event to all TableModelListeners that registered
themselves as listeners for this table model. |
TableCache |
getCache()
Retrieves the cache. |
abstract Class |
getColumnClass(int columnIndex)
Returns Object.class regardless of columnIndex . |
abstract String |
getColumnName(int column)
Returns a default name for the column using spreadsheet conventions: A, B, C, ... |
FilterTableModel |
getFilterTableModel()
Returns the internal filter tablemodel instance. |
int |
getRowCount()
Returns the number of rows in the model. |
SortTableModel |
getSortTableModel()
Returns the internal sort tablemodel instance. |
List |
getUncachedRows(int fromRow,
int toRow)
Retrieves the rows from the table model by specifying a row interval. |
Object |
getValueAt(int row,
int column)
Returns the value for the cell at columnIndex and
rowIndex . |
boolean |
isCountCached()
Determines whether the row count has been evaluated. |
boolean |
isRangedModel()
Determines whether the cache model can fetch data in ranges. |
boolean |
isValueCached(int row,
int column)
Determines whether the value at the specified cell has been evaluated. |
abstract void |
orderByClause()
This method is called whenever sorting is requested. |
protected Object |
retrieveFromDB(ResultSet rs,
int column)
Performs the binding from a database value to a java value using the supplied resultset and the column's index, and returns the result. |
protected Object |
retrieveFromDB(ResultSet rs,
int column,
Class c)
Performs the binding from a database value to a java value using the supplied resultset and the column's class, and returns the result. |
void |
setCache(TableCache newCache)
Assigns a new cache. |
void |
setRangedModel(boolean rangedModel)
Tells the database model whether to use ranges when fetching data from the database. |
abstract void |
whereClause()
This method is called whenever filtering is requested. |
Methods inherited from class javax.swing.table.AbstractTableModel |
---|
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, isCellEditable, removeTableModelListener, setValueAt |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods inherited from interface com.citra.table.db.DatabaseTableModel |
---|
readRowCount, retrieveRows |
Methods inherited from interface javax.swing.table.TableModel |
---|
addTableModelListener, getColumnCount, isCellEditable, removeTableModelListener, setValueAt |
Methods inherited from interface javax.swing.table.TableModel |
---|
addTableModelListener, getColumnCount, isCellEditable, removeTableModelListener, setValueAt |
Field Detail |
---|
protected int rowCount
protected SortTableModel dbSorter
protected FilterTableModel dbFilter
protected TableCache cache
protected boolean rangedModel
Constructor Detail |
---|
public AbstractDatabaseTableModel(TableCache cache)
Method Detail |
---|
public void fireTableChanged(TableModelEvent e)
TableModelListeners
that registered
themselves as listeners for this table model.
fireTableChanged
in class AbstractTableModel
e
- the event to be forwardedAbstractTableModel.addTableModelListener(javax.swing.event.TableModelListener)
,
TableModelEvent
,
EventListenerList
public TableCache getCache()
public abstract Class getColumnClass(int columnIndex)
Object.class
regardless of columnIndex
.
getColumnClass
in interface TableModel
getColumnClass
in class AbstractTableModel
columnIndex
- the column being queried
public abstract String getColumnName(int column)
column
cannot be found,
returns an empty string.
getColumnName
in interface TableModel
getColumnName
in class AbstractTableModel
column
- the column being queried
column
public FilterTableModel getFilterTableModel()
public int getRowCount()
JTable
uses this method to determine how many rows it
should display. This method should be quick, as it
is called frequently during rendering.
getRowCount
in interface TableModel
TableModel.getColumnCount()
public SortTableModel getSortTableModel()
public List getUncachedRows(int fromRow, int toRow)
getUncachedRows
in interface CacheableTableModel
fromRow
- the starting rowtoRow
- the ending row
public Object getValueAt(int row, int column)
columnIndex
and
rowIndex
.
getValueAt
in interface TableModel
row
- the row whose value is to be queriedcolumn
- the column whose value is to be queried
public boolean isCountCached()
isCountCached
in interface CacheableTableModel
public boolean isRangedModel()
isRangedModel
in interface CacheableTableModel
public boolean isValueCached(int row, int column)
isValueCached
in interface CacheableTableModel
row
- the cell's row indexcolumn
- the cell's column index
public abstract void orderByClause()
protected Object retrieveFromDB(ResultSet rs, int column) throws SQLException
rs
- the current result setcolumn
- the column being fetched
column
SQLException
protected Object retrieveFromDB(ResultSet rs, int column, Class c) throws SQLException
rs
- the current result setcolumn
- the column being fetchedc
- the column's class
column
SQLException
public void setCache(TableCache newCache)
newCache
- the new cache to assign.public void setRangedModel(boolean rangedModel)
rangedModel
- true if the database model is to return data in ranges, false otherwise.public abstract void whereClause()
|
Copyright © 2011 Citra Technologies. All Rights Reserved. | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |