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:

Other miscellaneous operations supported are:


Variable Index

 o fColumnSeparator
Actual column separator value.
 o fValueSeparator
Actual value separator for list of values.
 o kCOContains
Defines string contains operator for find operation.
 o kCOEndsWith
Defines string ends-with operator for find operation.
 o kCOEqual
Defines numeric or string equal operator for find operation.
 o kCOGreater
Defines numeric greater then operator for find operation.
 o kCOGreaterEqual
Defines numeric greater-equal then operator for find operation.
 o kCOLess
Defines numeric less then operator for find operation.
 o kCOLessEqual
Defines numeric less-equal then operator for find operation.
 o kColumnSeparator
Default column separator value
 o kCONotEqual
Defines numeric or string not-equal operator for find operation.
 o kCOStartsWith
Defines string starts-with operator for find operation.
 o kListOfNumbersType
Defines list of numeric column type.
 o kListOfStringsType
Defines list of string column type.
 o kNumberType
Defines numeric column type.
 o kStringType
Defines string column type.
 o kValueSeparator
Default value separator for list of values

Constructor Index

 o DBTable()

Method Index

 o appendToListValue(Object, Object)
Appends two values into list of values.
 o createIterator()
To iterate through all the records of the table, this creates an iterator.
 o find(Object[], byte[])
Find a set of records satisfying the given criteria.
 o getColumnCount()
Get the column count.
 o getColumnNames()
Get the column names.
 o getColumnTypes()
Get the column types.
 o getValueSeparator()
Get the value separator.
 o insertRecord(Object[])
Insert the given record.
 o insertRecordIfNotExist(Object[])
Insert the given record, only if a record with same primary key already does not exists.
 o makeListValue(Object[], int, int)
Makes a list of values out the individual values passed in the array.
 o print(PrintStream, String, DBIterator)
Print all the records in the iterator set.
 o print(PrintStream, String, Object[])
Print the given record.
 o recordExists(Object)
Check for existence of a record for the given primary key.
 o removeFromListValue(Object, Object)
Remove one value from the other.
 o removeRecord(Object)
Remove the record for the given primary key.
 o retreiveRecord(Object, Object[])
Retreive a record for the given primary key.
 o setHandleStale()
Set the DBTable object as stale.
 o splitListValue(String)
Break the list of values into individual values.
 o splitListValue(String, Object[], int, int)
Break the list of values into individual values.
 o updateRecord(Object, Object[])
Update the record for the given primary key with the new values.
 o verifyHandle()
Verify that the DBTable handle is not stale, if stale throw the exception.

Variables

 o kCOEqual
 public static final byte kCOEqual
Defines numeric or string equal operator for find operation.

 o kCONotEqual
 public static final byte kCONotEqual
Defines numeric or string not-equal operator for find operation.

 o kCOGreater
 public static final byte kCOGreater
Defines numeric greater then operator for find operation.

 o kCOGreaterEqual
 public static final byte kCOGreaterEqual
Defines numeric greater-equal then operator for find operation.

 o kCOLess
 public static final byte kCOLess
Defines numeric less then operator for find operation.

 o kCOLessEqual
 public static final byte kCOLessEqual
Defines numeric less-equal then operator for find operation.

 o kCOContains
 public static final byte kCOContains
Defines string contains operator for find operation.

 o kCOStartsWith
 public static final byte kCOStartsWith
Defines string starts-with operator for find operation.

 o kCOEndsWith
 public static final byte kCOEndsWith
Defines string ends-with operator for find operation.

 o kNumberType
 public static final String kNumberType
Defines numeric column type.

 o kListOfNumbersType
 public static final String kListOfNumbersType
Defines list of numeric column type.

 o kStringType
 public static final String kStringType
Defines string column type.

 o kListOfStringsType
 public static final String kListOfStringsType
Defines list of string column type.

 o kColumnSeparator
 public static final String kColumnSeparator
Default column separator value

 o kValueSeparator
 public static final String kValueSeparator
Default value separator for list of values

 o fColumnSeparator
 protected String fColumnSeparator
Actual column separator value. Used by the subclasses.

 o fValueSeparator
 protected String fValueSeparator
Actual value separator for list of values. Used by the subclasses.

Constructors

 o DBTable
 public DBTable()

Methods

 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o 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.
 o getColumnCount
 public abstract int getColumnCount()
Get the column count.

 o getValueSeparator
 public String getValueSeparator()
Get the value separator.

 o 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.
 o print
 public void print(PrintStream stream,
                   String separator,
                   Object record[])
Print the given record.

 o 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.
 o 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.
 o splitListValue
 public String[] splitListValue(String value)
Break the list of values into individual values. Helper method to manipulate list of values as column value.

 o 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.
 o 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.

 o 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.
 o 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