Package com.mckoi.database
Class TemporaryTable
- java.lang.Object
-
- com.mckoi.database.Table
-
- com.mckoi.database.AbstractDataTable
-
- com.mckoi.database.DefaultDataTable
-
- com.mckoi.database.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
-
-
Field Summary
-
Fields inherited from class com.mckoi.database.DefaultDataTable
row_count
-
Fields inherited from class com.mckoi.database.Table
DEBUG_QUERY
-
-
Constructor Summary
Constructors Constructor Description TemporaryTable(Database database, java.lang.String name, DataTableColumnDef[] fields)
The Constructor.TemporaryTable(DefaultDataTable based_on)
Constructs this TemporaryTable based on the given Table object.TemporaryTable(java.lang.String name, Table based_on)
Constructs this TemporaryTable based on the fields from the given Table object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
copyFrom(Table table, int row)
Copies the contents of the row of the given Table onto the end of this table.TObject
getCellContents(int column, int row)
Returns an object that represents the information in the given cell in the table.DataTableDef
getDataTableDef()
Returns a DataTableDef object that defines the name of the table and the layout of the columns of the table.boolean
hasRootsLocked()
Returns true if the table has its row roots locked (via the lockRoot(int) method.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.void
newRow()
Creates a new row where cells can be inserted into.RowEnumeration
rowEnumeration()
Returns an Enumeration of the rows in this table.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.void
setRowCell(TObject cell, int column, int row)
Sets the cell in the given column / row to the given value.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.void
setRowObject(TObject ob, int col_index)
Sets the cell in the column of the last row of this table to the given TObject.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.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.void
setupAllSelectableSchemes()
This should be called if you want to perform table operations on this TemporaryTable.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.-
Methods inherited from class com.mckoi.database.DefaultDataTable
blankSelectableSchemes, blankSelectableSchemes, clearColumnScheme, findFieldName, getColumnCount, getDatabase, getResolvedVariable, getRootColumnScheme, getRowCount
-
Methods inherited from class com.mckoi.database.AbstractDataTable
getTableName, toString, typeEquals
-
Methods inherited from class com.mckoi.database.Table
all, allColumnMatchesValue, any, columnContainsCell, columnContainsValue, columnMatchesValue, columnMerge, compareCells, Debug, distinct, distinct, dumpTo, emptySelect, exhaustiveSelect, fastFindFieldName, getColumnDefAt, getColumnScheme, getFirstCellContent, getFirstCellContent, getLastCellContent, getLastCellContent, getSingleCellContent, getSingleCellContent, getSystem, getTableAccessState, getTTypeForColumn, getTTypeForColumn, join, orderByColumn, orderByColumn, orderByColumn, orderByColumns, orderedRowList, outside, printGraph, rangeSelect, selectAll, selectAll, selectFirst, selectLast, selectRange, selectRest, simpleJoin, simpleSelect, singleRowSelect, toMap, union
-
-
-
-
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 interfaceTableDataSource
- Specified by:
getDataTableDef
in classTable
-
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 interfaceTableDataSource
- Specified by:
getCellContents
in classTable
-
rowEnumeration
public RowEnumeration rowEnumeration()
Returns an Enumeration of the rows in this table. Each call to 'nextRowIndex' returns the next valid row index in the table.- Specified by:
rowEnumeration
in interfaceTableDataSource
- Specified by:
rowEnumeration
in classTable
-
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.
-
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 classTable
-
hasRootsLocked
public boolean hasRootsLocked()
Returns true if the table has its row roots locked (via the lockRoot(int) method.- Specified by:
hasRootsLocked
in classTable
-
-