Package ca.spatial.table
Class MultiRowCache
java.lang.Object
javax.swing.table.AbstractTableModel
ca.spatial.table.AttributeStore
ca.spatial.table.MultiRowCache
- All Implemented Interfaces:
PopupActivationListener
,Serializable
,Comparable
,EventListener
,ListSelectionListener
,TableModel
This class lazily buffers the attributes from another store.
Changes to the other data store are only lazily observed, for example
visiting a different row or period will flush the cache. Values
are cached when they are read.
This is a read-only data store: write operations throw exceptions.
- See Also:
- Serialized Form
-
Field Summary
Fields inherited from class ca.spatial.table.AttributeStore
SELECT_ADD, SELECT_FROM, SELECT_NEW
-
Constructor Summary
ConstructorsConstructorDescriptionMultiRowCache(AttributeStore as, int maxEntries)
Construct the cache data store from another AttributeStore. -
Method Summary
Modifier and TypeMethodDescriptionvoid
buildIndex(int column)
Build an index on the column.void
changeSelection(BitSet values)
Change the list of selected records to the selection in the BitSetvoid
close()
Close the table and release resources.int
findColumn(String field, String shortName)
Get the column number of the given field in the given table.getAttributeFormat(int field)
Get the format descriptor for a given column.Get the original AttributeStore that this object is caching.int
Get the number of columns in this storegetFullColumnName(int column)
Return the full name of a column at a given position, including the short name of the table.Get the selection model that keeps track of selected records.int
Get the default time period that is used by this table when an explicit time period is not provided.int
Get the total number of periods that this store supportsint
Get the number of rows in this storeint
Return the number of selected rowsGet aBitSet
BitSet that represents the current selected records.Get the short name for this table.Get the synchronizer object for this table.getValueAt(int row, int column, int period)
Get a cell valueint
getYearForPeriod(int period)
Get the ending year for a given period.boolean
isSelectedIndex(int row)
Check if the specified record is currently selected.boolean
Check if the selection emptyint
Look up the row number for a key value in given column number.boolean
Change the selection status of records based on the result of evaluating an expression.setShortName(String name)
Set the short name for this table.void
setValueAt(Object object, int row, int column, int period)
Set the value in a cell and notify listeners that the value has changed.Methods inherited from class ca.spatial.table.AttributeStore
absoluteFile, absoluteFile, absolutePath, absolutePath, addCellEditors, addMenuItems, addPopupActivationListener, addRelate, addRelate, addTableModelListener, addToGlobalStoreList, allowsEditing, booleanValue, booleanValue, calculate, calculateField, calculateField, canIndex, clearSelection, compareTo, decodeCharset, doubleValue, doubleValue, exportCSV, exportCSV, exportCSV, exportCSV, exportCSV, exportCSV, exportDBF, exportDBF, exportDBF, exportDBF, exportDBF, findColumn, findSimilarColumnNames, getCachingLayer, getCachingLayer, getCanonicalName, getColumnClass, getColumnName, getColumnNames, getContextPeriods, getCwd, getEditMode, getMinMax, getMinMax, getMinMax, getMinMax, getMinMax, getOpenStore, getOpenStore, getOpenStore, getOpenStores, getPeriodWidth, getRowNodeRemap, getSelection, getSelection, getSnapshot, getSnapshot, getStoreByShortName, getStoreByTitle, getTableName, getTableSpec, getTitle, getValueAt, hasIndex, identifyRecords, integerValue, integerValue, isCellEditable, listify, listValue, listValue, makeLu, maybePopup, notifyPopupActivationListeners, openOrReuse, openOrReuse, queryTable, queryTable, quoteIfRequired, relativePath, removeFromGlobalStoreList, removePopupActivationListener, removeTableModelListener, select, selectAdd, selectFrom, selectNew, setCwd, setCwd, setEditMode, setListSelectionModel, setPeriod, setRowNodeRemap, setTableSpec, setTitle, setValueAt, showCube, showTable, toString, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, uniqueValues, valueChanged
Methods inherited from class javax.swing.table.AbstractTableModel
fireTableCellUpdated, fireTableChanged, fireTableDataChanged, fireTableRowsDeleted, fireTableRowsInserted, fireTableRowsUpdated, fireTableStructureChanged, getListeners, getTableModelListeners
-
Constructor Details
-
MultiRowCache
Construct the cache data store from another AttributeStore.- Parameters:
maxEntries
- the number of rows to cache
-
-
Method Details
-
close
public void close()Description copied from class:AttributeStore
Close the table and release resources. The table should be used again after this method has been called.In many cases you do not need to call this method when you are finished using a table. Most tables will close automatically when they are no longer referenced.
It is possible that this method will be deprecated or removed in a future release.
- Overrides:
close
in classAttributeStore
-
getAttributeFormat
Description copied from class:AttributeStore
Get the format descriptor for a given column.- Overrides:
getAttributeFormat
in classAttributeStore
- Parameters:
field
- The column of interest- Returns:
- The
AttributeFormat
for this field
-
getRowCount
public int getRowCount()Description copied from class:AttributeStore
Get the number of rows in this store- Specified by:
getRowCount
in interfaceTableModel
- Specified by:
getRowCount
in classAttributeStore
- Returns:
- the number of rows in this store
-
getColumnCount
public int getColumnCount()Description copied from class:AttributeStore
Get the number of columns in this store- Specified by:
getColumnCount
in interfaceTableModel
- Overrides:
getColumnCount
in classAttributeStore
- Returns:
- the number of columns in this store
-
getPeriodCount
public int getPeriodCount()Description copied from class:AttributeStore
Get the total number of periods that this store supports- Specified by:
getPeriodCount
in classAttributeStore
- Returns:
- The number of periods in this store
-
getPeriod
public int getPeriod()Description copied from class:AttributeStore
Get the default time period that is used by this table when an explicit time period is not provided.- Overrides:
getPeriod
in classAttributeStore
- Returns:
- the default period used for this store
-
getYearForPeriod
public int getYearForPeriod(int period)Description copied from class:AttributeStore
Get the ending year for a given period.- Specified by:
getYearForPeriod
in classAttributeStore
- Parameters:
period
- The period of interest- Returns:
- the year for a given period
-
getSynchronizer
Description copied from class:AttributeStore
Get the synchronizer object for this table. This object can be used to suspend the scheduling task as a set of calculations are carried out. Most tables will not have a synchronizer object. The only tables that will are tables that provide simulation results.- Overrides:
getSynchronizer
in classAttributeStore
-
buildIndex
public void buildIndex(int column)Description copied from class:AttributeStore
Build an index on the column. The index can then be used for speedy lookups. SeeAttributeStore.lookupRow(java.lang.Object, int)
.- Overrides:
buildIndex
in classAttributeStore
- Parameters:
column
- the column of interest
-
lookupRow
Description copied from class:AttributeStore
Look up the row number for a key value in given column number. This will search the column for a value, and return the row number that the value was found in. If the record is not found then -1 is returned. There is no guarantee of which record will be returned if there more than one record has the same value.- Overrides:
lookupRow
in classAttributeStore
- Parameters:
key
- The data value to search forcolumn
- the column to search within- Returns:
- the row number where the value was found
-
getValueAt
Description copied from class:AttributeStore
Get a cell value- Specified by:
getValueAt
in classAttributeStore
- Parameters:
row
- The row containing the cellcolumn
- The column containing the cellperiod
- The period of interest- Returns:
- An object containing the cell value.
-
setValueAt
Description copied from class:AttributeStore
Set the value in a cell and notify listeners that the value has changed.Implementing classes that override must call this method to ensure that joins are properly maintained.
- Overrides:
setValueAt
in classAttributeStore
- Parameters:
object
- The value to be set.row
- The row containing the cellcolumn
- The column containing the cellperiod
- The period of interest
-
isSelectionEmpty
public boolean isSelectionEmpty()Description copied from class:AttributeStore
Check if the selection empty- Overrides:
isSelectionEmpty
in classAttributeStore
- Returns:
- true if the selection is empty
-
isSelectedIndex
public boolean isSelectedIndex(int row)Description copied from class:AttributeStore
Check if the specified record is currently selected.- Overrides:
isSelectedIndex
in classAttributeStore
- Parameters:
row
- The row of interest- Returns:
- true if the record is selected
-
getListSelectionModel
Description copied from class:AttributeStore
Get the selection model that keeps track of selected records.- Overrides:
getListSelectionModel
in classAttributeStore
- Returns:
- the ListSelectionModel
-
changeSelection
Description copied from class:AttributeStore
Change the list of selected records to the selection in the BitSet- Overrides:
changeSelection
in classAttributeStore
- Parameters:
values
- The new selection
-
getSelection
Description copied from class:AttributeStore
Get aBitSet
BitSet that represents the current selected records.- Overrides:
getSelection
in classAttributeStore
- Returns:
- a
BitSet
representing the current selected records
-
getSelectedRowCount
public int getSelectedRowCount()Description copied from class:AttributeStore
Return the number of selected rows- Overrides:
getSelectedRowCount
in classAttributeStore
- Returns:
- the number of selected rows
-
getShortName
Description copied from class:AttributeStore
Get the short name for this table. This value can be used in column lookups to differentiate similarly named columns from different joined tables.- Overrides:
getShortName
in classAttributeStore
-
select
Description copied from class:AttributeStore
Change the selection status of records based on the result of evaluating an expression.- Overrides:
select
in classAttributeStore
- Parameters:
owner
- A reference to the controlling window.period
- The period to evaluate the expression against.expression
- The reselect expression.type
- The type of selection, which may be one of SELECT_NEW, SELECT_ADD, or SELECT_FROM.- Returns:
- true if query is executed
-
setShortName
Description copied from class:AttributeStore
Set the short name for this table. This value can be used in column lookups to differentiate similarly named columns from different joined tables.- Overrides:
setShortName
in classAttributeStore
-
getFullColumnName
Description copied from class:AttributeStore
Return the full name of a column at a given position, including the short name of the table.- Overrides:
getFullColumnName
in classAttributeStore
- Parameters:
column
- the column number of interest- Returns:
- the name of the column
-
findColumn
Description copied from class:AttributeStore
Get the column number of the given field in the given table. If the column is not found then return -1.- Overrides:
findColumn
in classAttributeStore
- Parameters:
field
- The name of the field to look upshortName
- The short name of the table to look up the the column in. If this attribute store has related tables, the column from the related table with the matching short name will be returned. If there is no table with a matching short name an exception will be thrown.
-
getCacheParent
Get the original AttributeStore that this object is caching.- Overrides:
getCacheParent
in classAttributeStore
-