Class MultiPeriodRamAttributeStore

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

public class MultiPeriodRamAttributeStore extends AttributeStore implements EditableTableModel
This class holds an in-memory AttributeStore. There are methods for adding, rearanging and removing rows. The method for adding rows must be overriden to create the appropriate values for each column.

This class has constructors to intitialze the table fron an existing table, or to construct an empty table with a specified set of columns.

There are also static methods to create summary tables from other tables.

This class is restricted to tables having a single time period.

See Also:
Serialized Form
  • Constructor Details

    • MultiPeriodRamAttributeStore

      public MultiPeriodRamAttributeStore(AttributeFormat[] f, Object[][][] cache, int[] periodWidths)
      Construct a new MultiPeriodRamAttributeStore. The column definitions are as specified, and the table is backed by the data in the cache that is provided.
      Parameters:
      f - The list of column spcifications
      cache - The array of data for the initial rows, columns and periods in this table.
      periodWidths - an array of the width of each period, including period 0
  • 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
    • clearAllRows

      public void clearAllRows()
      Remove all rows from this table
    • getCache

      public Object[][][] getCache()
      Return a reference to the underlying data for this table
    • 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
    • insertRow

      public void insertRow(Object[][] rowData, int pos)
      Insert a row of data at a given position in the table. The position must be a valid row number between 0 and the number of rows in the table.
      Parameters:
      rowData - an array containg the data to add
      pos - the row position to add the data at
    • insertRows

      public void insertRows(Object[][][] rowData, int pos)
      Insert multiple rows of data at a given position in the table. The position must be a valid row number between 0 and the number of rows in the table.
      Parameters:
      rowData - an array of arrays containg the rows to add
      pos - the row position to add the data at
    • addRow

      public void addRow(Object[] rowData)
      Add a row of data to the end of the table.
      Specified by:
      addRow in interface EditableTableModel
      Parameters:
      rowData - an array containg the data to add
    • addRow

      public void addRow(Object[][] rowData)
      Add a row of data to the end of the table.
      Parameters:
      rowData - an array containg the data to add
    • addRows

      public void addRows(Object[][][] rowData)
      Add multiple rows of data to the end of the table.
      Parameters:
      rowData - an array of arrays containg the rows to add
    • addRow

      public void addRow(Component parent)
      Add a row of data to the table using an interactive query. This method must be overridden to provide the interface to fill in the data.
      Specified by:
      addRow in interface EditableTableModel
    • removeRow

      public void removeRow(int row)
      Remove the row specified by the row number.
      Specified by:
      removeRow in interface EditableTableModel
    • moveRow

      public void moveRow(int from, int to)
      Description copied from interface: EditableTableModel
      Move the specified row to a new location
      Specified by:
      moveRow in interface EditableTableModel