Package com.mckoi.database
Class RowData
java.lang.Object
com.mckoi.database.RowData
- All Implemented Interfaces:
Types
Represents a row of data to be added into a table. The row data is linked
to a TableField that describes the cell information within a row.
There are two types of RowData object. Those that are empty and contain blank data, and those that contain information to either be inserted into a table, or has be retrieved from a row.
NOTE: Any RowData objects that need to be set to 'null' should be done so explicitly. NOTE: We must call a 'setColumnData' method for _every_ column in the row to form. NOTE: This method (or derived classes) must only use safe methods in DataTable. (ie. getRowCount, etc are out).
- Author:
- Tobias Downer
-
Field Summary
Fields inherited from interface com.mckoi.database.global.Types
DB_BINARY, DB_BLOB, DB_BOOLEAN, DB_NUMERIC, DB_NUMERIC_EXTENDED, DB_OBJECT, DB_STRING, DB_TIME, DB_UNKNOWN
-
Constructor Summary
ConstructorsConstructorDescriptionRowData
(TableDataSource table) The Constructor generates a blank row.RowData
(TransactionSystem system, int col_count) To create a RowData object without an underlying table. -
Method Summary
Modifier and TypeMethodDescriptionint
findFieldName
(String column_name) Finds the field in this RowData with the given name.getCellData
(int column) Returns the TObject that represents the information in the given column of the row.int
Returns the number of columns (cells) in this row.getColumnName
(int column) Returns the name of the given column number.void
setColumnData
(int column, TObject cell) Sets up a column by casting the value from the given TObject to a type that is compatible with the column.void
setColumnDataFromObject
(int column, Object ob) Sets up a column from an Object.void
setColumnDataFromTObject
(int column, TObject ob) Sets up a column from a TObject.void
setColumnToDefault
(int column, QueryContext context) Sets the given column number to the default value for this column.void
setColumnToNull
(int column) This is a special case situation for setting the column cell to 'null'.void
setDefaultForRest
(QueryContext context) Any columns in the row of data that haven't been set yet (they will be 'null') will be set to the default value during this method.void
setupEntire
(int[] col_indices, Expression[] exps, QueryContext context) Sets up an entire row given the array of Expressions and a list of indices to the columns to set.void
setupEntire
(int[] col_indices, List insert_elements, QueryContext context) Sets up an entire row given the list of insert elements and a list of indices to the columns to set.void
setupEntire
(Assignment[] assignments, QueryContext context) Sets up an entire row given the array of assignments.toString()
Returns a string representation of this row.
-
Constructor Details
-
RowData
To create a RowData object without an underlying table. This is for copying from one table to a different one. -
RowData
The Constructor generates a blank row.
-
-
Method Details
-
setColumnData
Sets up a column by casting the value from the given TObject to a type that is compatible with the column. This is useful when we are copying information from one table to another. -
setColumnDataFromObject
Sets up a column from an Object. -
setColumnDataFromTObject
Sets up a column from a TObject. -
setColumnToNull
public void setColumnToNull(int column) This is a special case situation for setting the column cell to 'null'. -
setColumnToDefault
Sets the given column number to the default value for this column. -
getCellData
Returns the TObject that represents the information in the given column of the row. -
getColumnName
Returns the name of the given column number. -
findFieldName
Finds the field in this RowData with the given name. -
getColumnCount
public int getColumnCount()Returns the number of columns (cells) in this row. -
setDefaultForRest
Any columns in the row of data that haven't been set yet (they will be 'null') will be set to the default value during this method. This should be called after the row data has initially been set with values from some source.- Throws:
DatabaseException
-
setupEntire
Sets up an entire row given the array of assignments. If any columns are left 'null' then they are filled with the default value.- Throws:
DatabaseException
-
setupEntire
public void setupEntire(int[] col_indices, List insert_elements, QueryContext context) throws DatabaseException Sets up an entire row given the list of insert elements and a list of indices to the columns to set. An insert element is either an expression that is resolved to a constant, or the string "DEFAULT" which indicates the value should be set to the default value of the column.- Throws:
DatabaseException
-
setupEntire
public void setupEntire(int[] col_indices, Expression[] exps, QueryContext context) throws DatabaseException Sets up an entire row given the array of Expressions and a list of indices to the columns to set. Any columns that are not set by this method are set to the default value as defined for the column.- Throws:
DatabaseException
-
toString
Returns a string representation of this row.
-