All Packages Class Hierarchy This Package Previous Next Index
Class com.infoplace.simpledb.DBTable
java.lang.Object
|
+----com.infoplace.simpledb.DBTable
- public abstract class DBTable
- extends Object
This class implements a table based on relational database model.
Each instance of this class represents a database table. The table
is defined by the user by providing the 'schema', that is,
the number of columns and for each column, its data type. The first
column is always assumed to be the primary key.
The data types supported are string, numeric (could be byte, short,
int, float, double), list of strings and list of numerics.
There is no limitation on number of columns per table and values
within each column can be variable length data.
It supports the standard operations like:
- insert a record into a table
- retrieve a record from a table
- update a record in a table
- remove a record from a table
- find records satisfying certain criteria
- iterate through all the records in the table
Other miscellaneous operations supported are:
- get the column names
- get the column types
- print records to a stream
-
fColumnSeparator
- Actual column separator value.
-
fValueSeparator
- Actual value separator for list of values.
-
kCOContains
- Defines string contains operator for find operation.
-
kCOEndsWith
- Defines string ends-with operator for find operation.
-
kCOEqual
- Defines numeric or string equal operator for find operation.
-
kCOGreater
- Defines numeric greater then operator for find operation.
-
kCOGreaterEqual
- Defines numeric greater-equal then operator for find operation.
-
kCOLess
- Defines numeric less then operator for find operation.
-
kCOLessEqual
- Defines numeric less-equal then operator for find operation.
-
kColumnSeparator
- Default column separator value
-
kCONotEqual
- Defines numeric or string not-equal operator for find operation.
-
kCOStartsWith
- Defines string starts-with operator for find operation.
-
kListOfNumbersType
- Defines list of numeric column type.
-
kListOfStringsType
- Defines list of string column type.
-
kNumberType
- Defines numeric column type.
-
kStringType
- Defines string column type.
-
kValueSeparator
- Default value separator for list of values
-
DBTable()
-
-
appendToListValue(Object, Object)
- Appends two values into list of values.
-
createIterator()
- To iterate through all the records of the table, this creates
an iterator.
-
find(Object[], byte[])
- Find a set of records satisfying the given criteria.
-
getColumnCount()
- Get the column count.
-
getColumnNames()
- Get the column names.
-
getColumnTypes()
- Get the column types.
-
getValueSeparator()
- Get the value separator.
-
insertRecord(Object[])
- Insert the given record.
-
insertRecordIfNotExist(Object[])
- Insert the given record, only if a record with same primary key
already does not exists.
-
makeListValue(Object[], int, int)
- Makes a list of values out the individual values passed in the
array.
-
print(PrintStream, String, DBIterator)
- Print all the records in the iterator set.
-
print(PrintStream, String, Object[])
- Print the given record.
-
recordExists(Object)
- Check for existence of a record for the given primary key.
-
removeFromListValue(Object, Object)
- Remove one value from the other.
-
removeRecord(Object)
- Remove the record for the given primary key.
-
retreiveRecord(Object, Object[])
- Retreive a record for the given primary key.
-
setHandleStale()
- Set the DBTable object as stale.
-
splitListValue(String)
- Break the list of values into individual values.
-
splitListValue(String, Object[], int, int)
- Break the list of values into individual values.
-
updateRecord(Object, Object[])
- Update the record for the given primary key with the new
values.
-
verifyHandle()
- Verify that the DBTable handle is not stale, if stale
throw the exception.
kCOEqual
public static final byte kCOEqual
- Defines numeric or string equal operator for find operation.
kCONotEqual
public static final byte kCONotEqual
- Defines numeric or string not-equal operator for find operation.
kCOGreater
public static final byte kCOGreater
- Defines numeric greater then operator for find operation.
kCOGreaterEqual
public static final byte kCOGreaterEqual
- Defines numeric greater-equal then operator for find operation.
kCOLess
public static final byte kCOLess
- Defines numeric less then operator for find operation.
kCOLessEqual
public static final byte kCOLessEqual
- Defines numeric less-equal then operator for find operation.
kCOContains
public static final byte kCOContains
- Defines string contains operator for find operation.
kCOStartsWith
public static final byte kCOStartsWith
- Defines string starts-with operator for find operation.
kCOEndsWith
public static final byte kCOEndsWith
- Defines string ends-with operator for find operation.
kNumberType
public static final String kNumberType
- Defines numeric column type.
kListOfNumbersType
public static final String kListOfNumbersType
- Defines list of numeric column type.
kStringType
public static final String kStringType
- Defines string column type.
kListOfStringsType
public static final String kListOfStringsType
- Defines list of string column type.
kColumnSeparator
public static final String kColumnSeparator
- Default column separator value
kValueSeparator
public static final String kValueSeparator
- Default value separator for list of values
fColumnSeparator
protected String fColumnSeparator
- Actual column separator value. Used by the subclasses.
fValueSeparator
protected String fValueSeparator
- Actual value separator for list of values. Used by the subclasses.
DBTable
public DBTable()
insertRecord
public abstract void insertRecord(Object record[]) throws DBException
- Insert the given record. This does not make explicit test for
existence a record with the same primary key.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
insertRecordIfNotExist
public abstract boolean insertRecordIfNotExist(Object record[]) throws DBException
- Insert the given record, only if a record with same primary key
already does not exists. It throws an exception, if such a record
exists.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
retreiveRecord
public abstract boolean retreiveRecord(Object key,
Object record[]) throws DBException
- Retreive a record for the given primary key.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
recordExists
public abstract boolean recordExists(Object key) throws DBException
- Check for existence of a record for the given primary key.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
updateRecord
public abstract boolean updateRecord(Object key,
Object record[]) throws DBException
- Update the record for the given primary key with the new
values.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
removeRecord
public abstract boolean removeRecord(Object key) throws DBException
- Remove the record for the given primary key.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
createIterator
public abstract DBIterator createIterator() throws DBException
- To iterate through all the records of the table, this creates
an iterator.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
find
public abstract Vector find(Object criteriaValue[],
byte criteriaType[]) throws DBException
- Find a set of records satisfying the given criteria.
- Parameters:
- criteriaValue - Array of the size of the record, with
some or all values non-null.
- criteriaType - Array of the size of the record, with
corresponding 'Compare Operator' (CO) values.
- Returns:
- A list of records satisfying the given criteria.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
getColumnNames
public abstract String[] getColumnNames() throws DBException
- Get the column names.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
getColumnTypes
public abstract String[] getColumnTypes() throws DBException
- Get the column types.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
getColumnCount
public abstract int getColumnCount()
- Get the column count.
getValueSeparator
public String getValueSeparator()
- Get the value separator.
print
public void print(PrintStream stream,
String separator,
DBIterator set) throws DBException
- Print all the records in the iterator set.
- Throws: DBException
- When the table object is stale or an
io error occurred. Look at the getMessage() for exact value.
print
public void print(PrintStream stream,
String separator,
Object record[])
- Print the given record.
setHandleStale
public abstract void setHandleStale() throws DBException
- Set the DBTable object as stale. Any further operation results
in an exception.
- Throws: DBException
- When the table object is stale.
verifyHandle
public abstract void verifyHandle() throws DBException
- Verify that the DBTable handle is not stale, if stale
throw the exception.
- Throws: DBException
- When the table object is stale.
splitListValue
public String[] splitListValue(String value)
- Break the list of values into individual values. Helper method
to manipulate list of values as column value.
splitListValue
public int splitListValue(String value,
Object result[],
int count,
int offset)
- Break the list of values into individual values. The values
filled into the array provided. Helper method
to manipulate list of values as column value.
- Parameters:
- value - The input string representing the list of values.
- result - The individual values are filled into the array.
- count - Indicates how many values to be filled in.
- offset - The start index into the result array to fill in.
appendToListValue
public String appendToListValue(Object value1,
Object value2)
- Appends two values into list of values. The values passed
can themselves be list of values. Helper method
to manipulate list of values as column value.
removeFromListValue
public String removeFromListValue(Object value1,
Object value2)
- Remove one value from the other. The values passed
can themselves be list of values. Helper method
to manipulate list of values as column value.
- Parameters:
- value1 - The values removed from.
- value2 - The values removed.
makeListValue
public String makeListValue(Object values[],
int count,
int offset)
- Makes a list of values out the individual values passed in the
array. Helper method to manipulate list of values as column value.
- Parameters:
- values - Array of individual values.
- count - Indicates how many values to be used.
- offset - The start index into the array.
All Packages Class Hierarchy This Package Previous Next Index