Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

javatools.db
Class DbTable  view DbTable download DbTable.java

java.lang.Object
  extended byjavatools.db.AbstractTable
      extended byjavatools.db.DbAbstractTable
          extended byjavatools.db.DbTable
All Implemented Interfaces:
DbResult, DbTableUser
Direct Known Subclasses:
DbCachedTable, DbReferencedTable

public class DbTable
extends DbAbstractTable
implements DbResult

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

Version:
0.2.0

Field Summary
(package private)  int columnCount
           
(package private)  java.util.List columns
          Contains the list of columns.
protected  DbDatabase db
          The database used for the connection.
(package private)  java.lang.Object[] defaultValues
          Contains the default values for this table.
(package private)  java.sql.ResultSet rs
          The real result set.
(package private)  java.sql.PreparedStatement stmt
          The statement that generated the result set.
 
Fields inherited from class javatools.db.AbstractTable
colNameMap, 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.
(package private)  DbColumn getAddColumn()
          Adds a column and returns it to the caller.
 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, inserter, inserter, simpleDeleter, simpleInserter, simpleInserter, simpleUpdater, updater
 
Methods inherited from class javatools.db.AbstractTable
equals, getColumnIndex, getColumnName, setColumnCount, setColumnName, usesTables
 
Methods inherited from class java.lang.Object
clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

columnCount

int columnCount

rs

java.sql.ResultSet rs
The real result set.


stmt

java.sql.PreparedStatement stmt
The statement that generated the result set.


columns

java.util.List columns
Contains the list of columns.


defaultValues

java.lang.Object[] defaultValues
Contains the default values for this table.


db

protected DbDatabase db
The database used for the connection.

Constructor Detail

DbTable

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

Method Detail

setResultSet

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


setTableName

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

Overrides:
setTableName in class AbstractTable

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

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

getColumnCount

public int getColumnCount()
Returns the number of columns.

Overrides:
getColumnCount in class AbstractTable

getDatabase

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

Overrides:
getDatabase in class DbAbstractTable

getFullTableName

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

Overrides:
getFullTableName in class AbstractTable

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.

Specified by:
iterator in interface DbResult

close

public void close()
           throws DbException
Closes this table.

Specified by:
close in interface DbResult

getConstraint

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

Specified by:
getConstraint in class DbAbstractTable

getDefault

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

Specified by:
getDefault in class DbAbstractTable

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

finalize

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


getAddColumn

DbColumn getAddColumn()
                throws DbException
Adds a column and returns it to the caller.