Copyright © 2011 Citra Technologies. All Rights Reserved.

com.citra.table.cache
Class CachedTableModel

java.lang.Object
  extended by javax.swing.table.AbstractTableModel
      extended by com.citra.table.TableMap
          extended by com.citra.table.cache.CachedTableModel
All Implemented Interfaces:
ReorderListener, CacheableTableModel, ReorderModel, Serializable, EventListener, TableModelListener, TableModel

public class CachedTableModel
extends TableMap
implements CacheableTableModel

CachedListTableModel wraps around a TableModel in order to provide for a caching mechanism.

See Also:
Serialized Form

Field Summary
protected  DefaultTableCache cache
          the cache
 
Fields inherited from class com.citra.table.TableMap
tableModel
 
Fields inherited from class javax.swing.table.AbstractTableModel
listenerList
 
Constructor Summary
CachedTableModel(TableModel model)
          Creates a CachedTableModel.
CachedTableModel(TableModel model, DefaultTableCache cache)
          Creates a CachedTableModel.
CachedTableModel(TableModel model, int chunkSize, int maximumCacheSize)
          Creates a CachedTableModel.
 
Method Summary
 void fireTableChanged(TableModelEvent e)
          Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model.
 DefaultTableCache getTableCache()
          Returns the cache store that is caching the underlying table model.
 List getUncachedRows(int from, int to)
          Retrieves the rows from the table model by specifying a row interval.
 Object getValueAt(int row, int column)
          Returns tableModel.getValueAt
 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.
 void setTableCache(DefaultTableCache cache)
          Assigns the cache store that will be used for caching the underlying table model.
 
Methods inherited from class com.citra.table.TableMap
addReorderListener, fireRowsMapped, fireRowsReordered, getColumnClass, getColumnCount, getColumnName, getModel, getRowCount, isCellEditable, removeReorderListener, rowsReordered, setModel, setValueAt, tableChanged
 
Methods inherited from class javax.swing.table.AbstractTableModel
addTableModelListener, findColumn, fireTableCellUpdated, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners, removeTableModelListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.table.TableModel
addTableModelListener, getColumnClass, getColumnCount, getColumnName, getRowCount, isCellEditable, removeTableModelListener, setValueAt
 

Field Detail

cache

protected DefaultTableCache cache
the cache

Constructor Detail

CachedTableModel

public CachedTableModel(TableModel model)
Creates a CachedTableModel.


CachedTableModel

public CachedTableModel(TableModel model,
                        int chunkSize,
                        int maximumCacheSize)
Creates a CachedTableModel.


CachedTableModel

public CachedTableModel(TableModel model,
                        DefaultTableCache cache)
Creates a CachedTableModel.

Method Detail

fireTableChanged

public void fireTableChanged(TableModelEvent e)
Forwards the given notification event to all TableModelListeners that registered themselves as listeners for this table model.

Overrides:
fireTableChanged in class AbstractTableModel
Parameters:
e - the event to be forwarded
See Also:
AbstractTableModel.addTableModelListener(javax.swing.event.TableModelListener), TableModelEvent, EventListenerList

getTableCache

public DefaultTableCache getTableCache()
Returns the cache store that is caching the underlying table model.

Returns:
the assigned cache store

getUncachedRows

public List getUncachedRows(int from,
                            int to)
Retrieves the rows from the table model by specifying a row interval. The following condition must be true: from >= to. The List returned must contain the row elements starting at from. However, the List may contain less elements than those specified in the range.

Specified by:
getUncachedRows in interface CacheableTableModel
Parameters:
from - the starting row
to - the ending row
Returns:
a list of objects, each element of which contains a row from the table model

getValueAt

public Object getValueAt(int row,
                         int column)
Returns tableModel.getValueAt

Specified by:
getValueAt in interface TableModel
Overrides:
getValueAt in class TableMap
Parameters:
row - the row whose value is to be queried
column - the column whose value is to be queried
Returns:
the value Object at the specified cell

isCountCached

public boolean isCountCached()
Determines whether the row count has been evaluated.

Specified by:
isCountCached in interface CacheableTableModel
Returns:
true if the model's row count has already been evaluated.

isRangedModel

public boolean isRangedModel()
Determines whether the cache model can fetch data in ranges.

Specified by:
isRangedModel in interface CacheableTableModel
Returns:
true if the cache model can fetch ranged data.

isValueCached

public boolean isValueCached(int row,
                             int column)
Determines whether the value at the specified cell has been evaluated.

Specified by:
isValueCached in interface CacheableTableModel
Parameters:
row - the cell's row index
column - the cell's column index
Returns:
true if the cell value at (row, column) has already been evaluated.

setTableCache

public void setTableCache(DefaultTableCache cache)
Assigns the cache store that will be used for caching the underlying table model.

Parameters:
cache - the cache store to assign

Copyright © 2011 Citra Technologies. All Rights Reserved.