Class TemporaryTable

  • All Implemented Interfaces:
    RootTable, TableDataSource

    public final class TemporaryTable
    extends DefaultDataTable
    This class represents a temporary table that is built from data that is not related to any underlying DataTable object from the database.

    For example, an aggregate function generates data would be put into a TemporaryTable.

    Author:
    Tobias Downer
    • Constructor Detail

      • TemporaryTable

        public TemporaryTable​(Database database,
                              java.lang.String name,
                              DataTableColumnDef[] fields)
        The Constructor.
      • TemporaryTable

        public TemporaryTable​(java.lang.String name,
                              Table based_on)
        Constructs this TemporaryTable based on the fields from the given Table object.
      • TemporaryTable

        public TemporaryTable​(DefaultDataTable based_on)
        Constructs this TemporaryTable based on the given Table object.
    • Method Detail

      • newRow

        public void newRow()
        Creates a new row where cells can be inserted into.
      • setRowCell

        public void setRowCell​(TObject cell,
                               int column,
                               int row)
        Sets the cell in the given column / row to the given value.
      • setRowCell

        public void setRowCell​(TObject cell,
                               java.lang.String col_name)
        Sets the cell in the column of the last row of this table to the given TObject.
      • setRowObject

        public void setRowObject​(TObject ob,
                                 int col_index,
                                 int row)
        Sets the cell in the column of the last row of this table to the given TObject.
      • setRowObject

        public void setRowObject​(TObject ob,
                                 java.lang.String col_name)
        Sets the cell in the column of the last row of this table to the given TObject.
      • setRowObject

        public void setRowObject​(TObject ob,
                                 int col_index)
        Sets the cell in the column of the last row of this table to the given TObject.
      • setCellFrom

        public void setCellFrom​(Table table,
                                int src_col,
                                int src_row,
                                java.lang.String to_col)
        Copies the cell from the given table (src_col, src_row) to the last row of the column specified of this table.
      • copyFrom

        public void copyFrom​(Table table,
                             int row)
        Copies the contents of the row of the given Table onto the end of this table. Only copies columns that exist in both tables.
      • setupAllSelectableSchemes

        public void setupAllSelectableSchemes()
        This should be called if you want to perform table operations on this TemporaryTable. It should be called *after* all the rows have been set. It generates SelectableScheme object which sorts the columns of the table and lets us execute Table operations on this table. NOTE: After this method is called, the table must not change in any way.
      • getDataTableDef

        public DataTableDef getDataTableDef()
        Description copied from class: Table
        Returns a DataTableDef object that defines the name of the table and the layout of the columns of the table. Note that for tables that are joined with other tables, the table name and schema for this object become mangled. For example, a table called 'PERSON' joined with a table called 'MUSIC' becomes a table called 'PERSON#MUSIC' in a null schema.
        Specified by:
        getDataTableDef in interface TableDataSource
        Specified by:
        getDataTableDef in class Table
      • getCellContents

        public TObject getCellContents​(int column,
                                       int row)
        Returns an object that represents the information in the given cell in the table. This can be used to obtain information about the given table cells.
        Specified by:
        getCellContents in interface TableDataSource
        Specified by:
        getCellContents in class Table
      • lockRoot

        public void lockRoot​(int lock_key)
        Locks the root table(s) of this table so that it is impossible to overwrite the underlying rows that may appear in this table. This is used when cells in the table need to be accessed 'outside' the lock. So we may have late access to cells in the table. 'lock_key' is a given key that will also unlock the root table(s). NOTE: This is nothing to do with the 'LockingMechanism' object.
        Specified by:
        lockRoot in class Table
      • unlockRoot

        public void unlockRoot​(int lock_key)
        Unlocks the root tables so that the underlying rows may once again be used if they are not locked and have been removed. This should be called some time after the rows have been locked.
        Specified by:
        unlockRoot in class Table
      • hasRootsLocked

        public boolean hasRootsLocked()
        Returns true if the table has its row roots locked (via the lockRoot(int) method.
        Specified by:
        hasRootsLocked in class Table