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.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.mckoi.database.Table
Table.TableVariableResolver
-
-
Field Summary
Fields Modifier and Type Field Description private DataTableDef
table_def
The DataTableDef object that describes the columns in this table.private java.util.ArrayList
table_storage
A Vector that represents the storage of TObject[] arrays for each row of the table.-
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 Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addDataTableListener(DataTableListener listener)
Adds a DataTableListener to the DataTable objects at the root of this table tree hierarchy.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.(package private) void
removeDataTableListener(DataTableListener listener)
Removes a DataTableListener from the DataTable objects at the root of this table tree hierarchy.private Variable
resolveToVariable(java.lang.String col_name)
Resolves the given column name (eg 'id' or 'Customer.id' or 'APP.Customer.id') to a column in this table.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.(package private) static TemporaryTable
singleColumnTable(Database database, java.lang.String col_name, java.lang.Class c)
Creates a table with a single column with the given name and type.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
addCellToColumnSchemes, addRowToColumnSchemes, blankSelectableSchemes, blankSelectableSchemes, clearColumnScheme, findFieldName, getColumnCount, getDatabase, getResolvedVariable, getRootColumnScheme, getRowCount, getSelectableSchemeFor, removeRowToColumnSchemes, resolveToRawTable, setToRowTableDomain
-
Methods inherited from class com.mckoi.database.AbstractDataTable
getTableName, toString, typeEquals
-
Methods inherited from class com.mckoi.database.Table
all, allColumnMatchesValue, allRowsIn, allRowsNotIn, 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, getVariableResolver, join, orderByColumn, orderByColumn, orderByColumn, orderByColumns, orderedRowList, outside, printGraph, rangeSelect, selectAll, selectAll, selectFirst, selectFromPattern, selectFromRegex, selectLast, selectRange, selectRest, selectRows, selectRows, selectRows, simpleJoin, simpleSelect, singleRowSelect, toMap, union
-
-
-
-
Field Detail
-
table_def
private DataTableDef table_def
The DataTableDef object that describes the columns in this table.
-
table_storage
private java.util.ArrayList table_storage
A Vector that represents the storage of TObject[] arrays for each row of the table.
-
-
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
-
resolveToVariable
private Variable resolveToVariable(java.lang.String col_name)
Resolves the given column name (eg 'id' or 'Customer.id' or 'APP.Customer.id') to a column in this table.
-
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
-
addDataTableListener
void addDataTableListener(DataTableListener listener)
Adds a DataTableListener to the DataTable objects at the root of this table tree hierarchy. If this table represents the join of a number of tables then the DataTableListener is added to all the DataTable objects at the root.A DataTableListener is notified of all modifications to the raw entries of the table. This listener can be used for detecting changes in VIEWs, for triggers or for caching of common queries.
- Specified by:
addDataTableListener
in classTable
-
removeDataTableListener
void removeDataTableListener(DataTableListener listener)
Removes a DataTableListener from the DataTable objects at the root of this table tree hierarchy. If this table represents the join of a number of tables, then the DataTableListener is removed from all the DataTable objects at the root.- Specified by:
removeDataTableListener
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
-
singleColumnTable
static final TemporaryTable singleColumnTable(Database database, java.lang.String col_name, java.lang.Class c)
Creates a table with a single column with the given name and type.
-
-