Package com.mckoi.database
Class SimpleTableQuery
java.lang.Object
com.mckoi.database.SimpleTableQuery
A simple convenience interface for querying a MutableTableDataSource
instance. This is used as a very lightweight interface for changing a
table. It is most useful for internal low level users of a database
table which doesn't need the overhead of the Mckoi table hierarchy
mechanism.
- Author:
- Tobias Downer
-
Constructor Summary
ConstructorsConstructorDescriptionSimpleTableQuery
(TableDataSource in_table) Constructs the SimpleTableQuery with the given MutableTableDataSource object. -
Method Summary
Modifier and TypeMethodDescriptionvoid
deleteRows
(IntegerVector list) Deletes all the given indexes in this table.boolean
deleteSingle
(int col, Object val) Deletes a single entry from the table where the given column equals the given value.void
dispose()
Disposes this object and frees any resources associated with it.boolean
existsSingle
(int col, Object val) Returns true if there is a single row in the table where the given column is equal to the given value, otherwise returns false.void
finalize()
To be save we call dispose from the finalize method.get
(int column, int row) Gets the TObject at the given cell in the table.int
Returns the total number of rows in this table.Assuming the table stores a key/value mapping, this returns the contents of value_column for any rows where key_column is equal to the key_value.Returns a RowEnumeration that is used to iterate through the entire list of valid rows in the table.selectIndexesEqual
(int column, TObject cell) Finds the index of all the rows in the table where the given column is equal to the given object.selectIndexesEqual
(int col1, TObject cell1, int col2, TObject cell2) Finds the index of all the rows in the table where the given column is equal to the given object for both of the clauses.selectIndexesEqual
(int column, Object value) Finds the index of all the rows in the table where the given column is equal to the given object.selectIndexesEqual
(int col1, Object val1, int col2, Object val2) Finds the index of all the rows in the table where the given column is equal to the given object for both of the clauses.void
Adds a new key/value mapping in this table.
-
Constructor Details
-
SimpleTableQuery
Constructs the SimpleTableQuery with the given MutableTableDataSource object.
-
-
Method Details
-
rowEnumeration
Returns a RowEnumeration that is used to iterate through the entire list of valid rows in the table. -
getRowCount
public int getRowCount()Returns the total number of rows in this table. -
get
Gets the TObject at the given cell in the table. Note that the offset between one valid row and the next may not necessily be 1. It is possible for there to be gaps in the data. For an iterator that returns successive row indexes, use the 'rowEnumeration' method. -
selectIndexesEqual
Finds the index of all the rows in the table where the given column is equal to the given object. -
selectIndexesEqual
Finds the index of all the rows in the table where the given column is equal to the given object.We assume value is not null, and it is either a BigNumber to represent a number, a String, a java.util.Date or a ByteLongObject.
-
selectIndexesEqual
Finds the index of all the rows in the table where the given column is equal to the given object for both of the clauses. This implies an AND for the two searches. -
selectIndexesEqual
Finds the index of all the rows in the table where the given column is equal to the given object for both of the clauses. This implies an AND for the two searches.We assume value is not null, and it is either a BigNumber to represent a number, a String, a java.util.Date or a ByteLongObject.
-
existsSingle
Returns true if there is a single row in the table where the given column is equal to the given value, otherwise returns false. If there are 2 or more rows an assertion exception is thrown. -
getVar
Assuming the table stores a key/value mapping, this returns the contents of value_column for any rows where key_column is equal to the key_value. An assertion exception is thrown if there is more than 2 rows that match the key. If no rows match the key then null is returned. -
setVar
Adds a new key/value mapping in this table. If the key already exists the old key/value row is deleted first. This method accepts two arguments, the column that contains the key value, and an Object[] array that is the list of cells to insert into the table. The Object[] array must be the size of the number of columns in this tbale.NOTE: Change will come into effect globally at the next commit.
NOTE: This method must be assured of exlusive access to the table within the transaction.
NOTE: This only works if the given table implements MutableTableDataSource.
-
deleteSingle
Deletes a single entry from the table where the given column equals the given value. If there are multiple values found an assertion exception is thrown. If a single value was found and deleted 'true' is returned otherwise false.NOTE: This only works if the given table implements MutableTableDataSource.
-
deleteRows
Deletes all the given indexes in this table.NOTE: This only works if the given table implements MutableTableDataSource.
-
dispose
public void dispose()Disposes this object and frees any resources associated with it. This should be called when the query object is no longer being used. -
finalize
public void finalize()To be save we call dispose from the finalize method.
-