Class MultiRowCache

All Implemented Interfaces:
PopupActivationListener, Serializable, Comparable, EventListener, ListSelectionListener, TableModel

public class MultiRowCache extends AttributeStore
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
  • Constructor Details

    • MultiRowCache

      public MultiRowCache(AttributeStore as, int maxEntries)
      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 class AttributeStore
    • getAttributeFormat

      public AttributeFormat getAttributeFormat(int field)
      Description copied from class: AttributeStore
      Get the format descriptor for a given column.
      Overrides:
      getAttributeFormat in class AttributeStore
      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 interface TableModel
      Specified by:
      getRowCount in class AttributeStore
      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 interface TableModel
      Overrides:
      getColumnCount in class AttributeStore
      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 class AttributeStore
      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 class AttributeStore
      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 class AttributeStore
      Parameters:
      period - The period of interest
      Returns:
      the year for a given period
    • getSynchronizer

      public Suspendable 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 class AttributeStore
    • 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. See AttributeStore.lookupRow(java.lang.Object, int).
      Overrides:
      buildIndex in class AttributeStore
      Parameters:
      column - the column of interest
    • lookupRow

      public int lookupRow(Object key, int column)
      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 class AttributeStore
      Parameters:
      key - The data value to search for
      column - the column to search within
      Returns:
      the row number where the value was found
    • getValueAt

      public Object getValueAt(int row, int column, int period)
      Description copied from class: AttributeStore
      Get a cell value
      Specified by:
      getValueAt in class AttributeStore
      Parameters:
      row - The row containing the cell
      column - The column containing the cell
      period - The period of interest
      Returns:
      An object containing the cell value.
    • setValueAt

      public void setValueAt(Object object, int row, int column, int period)
      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 class AttributeStore
      Parameters:
      object - The value to be set.
      row - The row containing the cell
      column - The column containing the cell
      period - The period of interest
    • isSelectionEmpty

      public boolean isSelectionEmpty()
      Description copied from class: AttributeStore
      Check if the selection empty
      Overrides:
      isSelectionEmpty in class AttributeStore
      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 class AttributeStore
      Parameters:
      row - The row of interest
      Returns:
      true if the record is selected
    • getListSelectionModel

      public DefaultListSelectionModel getListSelectionModel()
      Description copied from class: AttributeStore
      Get the selection model that keeps track of selected records.
      Overrides:
      getListSelectionModel in class AttributeStore
      Returns:
      the ListSelectionModel
    • changeSelection

      public void changeSelection(BitSet values)
      Description copied from class: AttributeStore
      Change the list of selected records to the selection in the BitSet
      Overrides:
      changeSelection in class AttributeStore
      Parameters:
      values - The new selection
    • getSelection

      public BitSet getSelection()
      Description copied from class: AttributeStore
      Get a BitSetBitSet that represents the current selected records.
      Overrides:
      getSelection in class AttributeStore
      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 class AttributeStore
      Returns:
      the number of selected rows
    • getShortName

      public String 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 class AttributeStore
    • select

      public boolean select(Window owner, int period, String expression, int type)
      Description copied from class: AttributeStore
      Change the selection status of records based on the result of evaluating an expression.
      Overrides:
      select in class AttributeStore
      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

      public AttributeStore setShortName(String name)
      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 class AttributeStore
    • getFullColumnName

      public FullColumnName getFullColumnName(int column)
      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 class AttributeStore
      Parameters:
      column - the column number of interest
      Returns:
      the name of the column
    • findColumn

      public int findColumn(String field, String shortName)
      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 class AttributeStore
      Parameters:
      field - The name of the field to look up
      shortName - 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

      public AttributeStore getCacheParent()
      Get the original AttributeStore that this object is caching.
      Overrides:
      getCacheParent in class AttributeStore