JClass DesktopViews 6.3.0 API
Documentation

com.klg.jclass.table.data
Class JCCachedDataSource

java.lang.Object
  |
  +--com.klg.jclass.table.data.AbstractDataSource
        |
        +--com.klg.jclass.table.data.AbstractVectorDataSource
              |
              +--com.klg.jclass.table.data.JCCachedDataSource
All Implemented Interfaces:
EventListener, JCTableDataListener, JCTableDataModel, Serializable, TableDataModel
Direct Known Subclasses:
JCEditableCachedDataSource

public class JCCachedDataSource
extends AbstractVectorDataSource
implements JCTableDataListener

The JCCachedDataSource class stores data in a Vector of Vectors. Unlike other data sources, the source for label and cell data is another TableData class. If the object stored for the cell or label is null, the call passes through to the contained TableData class, and the value is fetched and stored in JCCachedDataSource. JCCachedDataSource should only be used when the actual TableData's getTableDataItem, getTableRowLabel, or getTableColumnLabel are calculation-intensive or expensive to fetch. Although JCCachedDataSource can bind to any data source, it implements TableData and not EditableTableData, and is therefore not editable. Use EditableCachedDataSource to bind to an editable data source and have edit functionality.
Note: A non-editable data source bound to JCEditableCachedDataSource will display an editor but reject all changes.

Since:
JClass 4.0K for Java 2. If you are using JClass 4.0J, which is based on JDK 1.1, some of the return types for this class' fields or methods are based on the corresponding com.sun.java.util class.
See Also:
Serialized Form

Field Summary
protected  Vector cached_cells
           
protected  Vector cached_column_labels
           
protected  Vector cached_row_labels
           
protected  com.klg.jclass.table.TableDataModel dataSource
          The actual source of data.
 
Fields inherited from class com.klg.jclass.table.data.AbstractDataSource
listeners
 
Constructor Summary
JCCachedDataSource(com.klg.jclass.table.TableDataModel source)
          Creates a new TableDataModel caching data source.
 
Method Summary
 void dataChanged(com.klg.jclass.table.JCTableDataEvent e)
          Listens for JCTableDataEvents on the contained data source.
 int getNumColumns()
          Returns the number of columns in the contained data source.
 int getNumRows()
          Returns the number of rows in the contained data source.
 Object getTableColumnLabel(int column)
          Returns the value for the column label at the specified column.
 Object getTableDataItem(int row, int column)
          Returns the value for the cell at the specified location.
 Object getTableRowLabel(int row)
          Returns the value for the row label at the specified row.
 
Methods inherited from class com.klg.jclass.table.data.AbstractVectorDataSource
createVector, createVector, createVector, createVector, createVector, removeElementsAt, setElementAt, strip
 
Methods inherited from class com.klg.jclass.table.data.AbstractDataSource
addTableDataListener, dispose, fireColumnChanged, fireColumnLabelChanged, fireColumnsAdded, fireColumnsDeleted, fireColumnsMoved, fireDataReset, fireNumColumnsChanged, fireNumRowsChanged, fireRowChanged, fireRowDeleted, fireRowLabelChanged, fireRowsAdded, fireRowsMoved, fireTableDataEvent, fireValueChanged, hasListeners, removeTableDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

dataSource

protected com.klg.jclass.table.TableDataModel dataSource
The actual source of data.


cached_row_labels

protected Vector cached_row_labels

cached_column_labels

protected Vector cached_column_labels

cached_cells

protected Vector cached_cells
Constructor Detail

JCCachedDataSource

public JCCachedDataSource(com.klg.jclass.table.TableDataModel source)
Creates a new TableDataModel caching data source.

Parameters:
source -
Method Detail

getNumRows

public int getNumRows()
Returns the number of rows in the contained data source. Row count is not cached.

Specified by:
getNumRows in interface JCTableDataModel
Returns:
number of rows in the contained data source

getNumColumns

public int getNumColumns()
Returns the number of columns in the contained data source. Column count is not cached.

Specified by:
getNumColumns in interface JCTableDataModel
Returns:
number of columns in the contained data source

getTableDataItem

public Object getTableDataItem(int row,
                               int column)
Returns the value for the cell at the specified location. If the cache is null, the contained data source is read and the value is stored in the cache.

Specified by:
getTableDataItem in interface JCTableDataModel
Parameters:
row -
column -
Returns:
value for the cell at the specified location

getTableRowLabel

public Object getTableRowLabel(int row)
Returns the value for the row label at the specified row. If the cache is null, the contained data source is read and the value is stored in the cache.

Specified by:
getTableRowLabel in interface JCTableDataModel
Parameters:
row -
Returns:
value for the row label at the specified row

getTableColumnLabel

public Object getTableColumnLabel(int column)
Returns the value for the column label at the specified column. If the cache is null, the contained data source is read and the value is stored in the cache.

Specified by:
getTableColumnLabel in interface JCTableDataModel
Parameters:
column -
Returns:
value for the column label at the specified column

dataChanged

public void dataChanged(com.klg.jclass.table.JCTableDataEvent e)
Listens for JCTableDataEvents on the contained data source. A simplistic approach has been taken to dirty the cache. For single cell changes, the element is set to null so that the next read forces a re-read of the contained data source. For row specific changes, the row and cell cache is nulled; for column specific changes, the column and cell cache is nulled. Reset nulls everything.

Specified by:
dataChanged in interface JCTableDataListener
Parameters:
e -

Copyright © 2004 Quest Software Inc..
All rights reserved.