Class TransientUpdateStore

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

public class TransientUpdateStore extends AttributeStore
This class provides a wrapper around other AttributeStore objects, and allows fields in those objects to be temporarily updated with user specified values. The updated values are not permanent, and are reset to initial conditions upon request.

This class only keeps track of updates on a single record at at time. As soon as the record of interest is changed then the original values are read in from the underlying stream.

This class also allows the addition of user defined fields. These fields are not present in the original data stream. The values of user defined fields are initially "" or 0, but may be modified using the setValueAt methods. User defined values are not lost when the record of interest changes.

This store understands the concept of time periods, although this is irrelevant for any dataset read from a file.

This class can also be instantiated with no-args constructor, in which case no values come from the underlying data store. In this case the store is a single row in length, and only has columns that have been added with the addColumn() method.

The store supports a stack-based approach to tracking changes to variable values. The current values of all attributes can be 'pushed' on to a stack. When the variables are later 'popped' they will resume their former values. There is also a peek() method to retrieve the stack values without changing the stack, and a getStackSize method to determine the number of elements in the stack. Calling reloadCache will clear the stack.

This class should be thread safe.

See Also:
Serialized Form
  • Constructor Details

    • TransientUpdateStore

      public TransientUpdateStore()
    • TransientUpdateStore

      public TransientUpdateStore(AttributeStore as)
  • Method Details

    • 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
    • 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
    • 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
    • addColumn

      public int addColumn(String name, int type, int width, int dec)
      Add a new column to this attribute store. This column is not present in the underlying data store and values only come from the user. The initial value in any user defined column is "" for String, 0 for numbers, false for boolean.
    • addColumn

      public int addColumn(AttributeFormat f)
    • setColumnCount

      public void setColumnCount(int count)
      A special version of setColumnCount that allows additional fields to be defined.
    • getValueAt

      public Object getValueAt(int row, int column, int period)
      Retrieve an object from the store.
      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 aValue, int row, int column, int period)
      Set an object in the store
      Overrides:
      setValueAt in class AttributeStore
      Parameters:
      aValue - The value to be set.
      row - The row containing the cell
      column - The column containing the cell
      period - The period of interest
    • reloadCache

      public void reloadCache(int row, int period)
      Reload the original values for a given record and time period. This routine will not touch the user-defined fields.

      The stack will be emptied after calling this routine.

    • reloadCache

      public void reloadCache(int row)
      Reload the cached values for a given record at the default period.
    • push

      public void push()
    • peek

      public void peek()
    • pop

      public void pop()
    • getStackSize

      public int getStackSize()