javatools.db
Class DbTable

java.lang.Object
  |
  +--javatools.db.DbAbstractTable
        |
        +--javatools.db.DbTable
All Implemented Interfaces:
DbTableUser
Direct Known Subclasses:
DbCachedTable, DbReferencedTable

public class DbTable
extends DbAbstractTable

A class representing tabular data. Could be a real database table or the result of a SELECT.


Field Summary
 
Fields inherited from class javatools.db.DbAbstractTable
db, displaySize, names, tableName, types
 
Constructor Summary
DbTable(DbDatabase db)
          Creates a new DbTable.
 
Method Summary
 void close()
          Closes this table.
protected  void finalize()
          Destroys this object.
 DbColumn getColumn(int index)
          Get the column of the given index.
 DbColumn getColumn(java.lang.String name)
          Get the DbColumn representing the column with this name.
 int getColumnCount()
          Returns the number of columns.
 DbConstraint getConstraint()
          Returns null (no constraint in a simple DbTable).
 DbDatabase getDatabase()
          Get the database that this table came fr
 java.lang.Object getDefault(int index)
          Returns the default value for this table.
 java.lang.Object getDefault(java.lang.String name)
          Returns the default value of a column.
 java.lang.String getFullTableName()
          Returns the complete table name.
 DbIterator iterator()
          Return an iterator to iterate over the rows in this table.
 void setResultSet(java.sql.PreparedStatement stmt, java.sql.ResultSet rs)
          Sets the result set to take rows from.
 void setTableName(java.lang.String v)
          Sets the table name.
 
Methods inherited from class javatools.db.DbAbstractTable
deleter, equals, inserter, inserter, simpleDeleter, simpleInserter, simpleInserter, simpleUpdater, updater, usesTables
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbTable

public DbTable(DbDatabase db)
        throws DbException
Creates a new DbTable.

Parameters:
db - The database to use.
Throws:
DbException - If something goes wrong.
Method Detail

setResultSet

public void setResultSet(java.sql.PreparedStatement stmt,
                         java.sql.ResultSet rs)
                  throws DbException
Sets the result set to take rows from.

Parameters:
stmt - The statement that generated the result set. It can be null.
rs - The result set to use.
Throws:
DbException - If something goes wrong.

setTableName

public void setTableName(java.lang.String v)
Sets the table name.

Overrides:
setTableName in class DbAbstractTable
Parameters:
v - The new table name.

getColumn

public DbColumn getColumn(java.lang.String name)
                   throws DbException
Get the DbColumn representing the column with this name.

Specified by:
getColumn in class DbAbstractTable
Parameters:
name - The name of the column.
Returns:
The column value
Throws:
DbException - If something goes wrong.

getColumn

public DbColumn getColumn(int index)
                   throws DbException
Get the column of the given index. Index is a zero based array.

Specified by:
getColumn in class DbAbstractTable
Parameters:
index - The index of the column.
Returns:
The column value
Throws:
DbException - If something goes wrong.

getColumnCount

public int getColumnCount()
Returns the number of columns.

Specified by:
getColumnCount in class DbAbstractTable
Returns:
The column count.

getDatabase

public DbDatabase getDatabase()
Get the database that this table came fr

Overrides:
getDatabase in class DbAbstractTable
Returns:
The database value

getFullTableName

public java.lang.String getFullTableName()
Returns the complete table name.

Overrides:
getFullTableName in class DbAbstractTable
Returns:
The complete table name.

iterator

public DbIterator iterator()
Return an iterator to iterate over the rows in this table.

BUGS: Currently you can only iterate over a table that was returned from a DbSelector.

Returns:
The requested iterator.

close

public void close()
           throws DbException
Closes this table.

Throws:
DbException - If something goes wrong.

getConstraint

public DbConstraint getConstraint()
Returns null (no constraint in a simple DbTable).

Specified by:
getConstraint in class DbAbstractTable
Returns:
null.

getDefault

public java.lang.Object getDefault(int index)
                            throws DbException
Returns the default value for this table.

Specified by:
getDefault in class DbAbstractTable
Parameters:
index - The index of the requested column.
Returns:
The needed default value.
Throws:
DbException - If something goes wrong.

getDefault

public java.lang.Object getDefault(java.lang.String name)
                            throws DbException
Returns the default value of a column.

Specified by:
getDefault in class DbAbstractTable
Parameters:
name - The name of the column.
Returns:
The requested default value.
Throws:
DbException - If something goes wrong.

finalize

protected void finalize()
                 throws java.lang.Throwable
Destroys this object.

Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable - If something goes wrong.