javatools.db
Class DbJoinedTable

java.lang.Object
  |
  +--javatools.db.DbAbstractTable
        |
        +--javatools.db.DbJoinedTable
All Implemented Interfaces:
DbTableUser

public class DbJoinedTable
extends DbAbstractTable

This class represents a "joined table" in an SQL statement.


Field Summary
static int INNER_JOIN
          Represents an inner join.
static int LEFT_JOIN
          Represents a left join.
static int NATURAL_JOIN
          Represents a left join.
static int OUTER_JOIN
          Represents an outer join.
static int RIGHT_JOIN
          Represents a right join.
 
Fields inherited from class javatools.db.DbAbstractTable
db, displaySize, names, tableName, types
 
Constructor Summary
DbJoinedTable(DbDatabase db, DbAbstractTable tabLeft, DbAbstractTable tabRight, int pJoinType, DbExpr pJoinCondition)
          Creates a new instance of DbJoinedTable
 
Method Summary
 DbDeleter deleter()
          Returns a deleter for deleting rows in the database.
 boolean equals(java.lang.Object o)
          Check if an object is equal to the current one.
 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 the DbConstraint object associated with this table.
 java.lang.Object getDefault(int index)
          Returns the default value for the field at the given index.
 java.lang.Object getDefault(java.lang.String name)
          Returns the default value for the field whose name is specified.
 DbInserter inserter()
          Return an inserter for inserting new data in the database.
 DbInserter inserter(DbSelector selector)
          Return an inserter for inserting new data in the database.
 void setTableName(java.lang.String v)
          Sets the name of the referenced table.
 DbDeleter simpleDeleter()
          Returns a deleter for deleting rows in the database.
 DbInserter simpleInserter()
          Return an inserter for inserting new data in the database.
 DbInserter simpleInserter(DbSelector selector)
          Return an inserter for inserting new data in the database.
 DbUpdater simpleUpdater()
          Return an updater for updating rows in the database.
 DbUpdater updater()
          Return an updater for updating rows in the database.
 void usesTables(java.util.Set c)
          Returns the base tables used in this joined table.
 
Methods inherited from class javatools.db.DbAbstractTable
getDatabase, getFullTableName
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

INNER_JOIN

public static final int INNER_JOIN
Represents an inner join.

See Also:
Constant Field Values

NATURAL_JOIN

public static final int NATURAL_JOIN
Represents a left join.

See Also:
Constant Field Values

LEFT_JOIN

public static final int LEFT_JOIN
Represents a left join.

See Also:
Constant Field Values

RIGHT_JOIN

public static final int RIGHT_JOIN
Represents a right join.

See Also:
Constant Field Values

OUTER_JOIN

public static final int OUTER_JOIN
Represents an outer join.

See Also:
Constant Field Values
Constructor Detail

DbJoinedTable

public DbJoinedTable(DbDatabase db,
                     DbAbstractTable tabLeft,
                     DbAbstractTable tabRight,
                     int pJoinType,
                     DbExpr pJoinCondition)
              throws DbException
Creates a new instance of DbJoinedTable

Parameters:
db - The database to use.
tabLeft - The left table to be joined.
tabRight - The right table to be joined.
pJoinType - The join type to use.
pJoinCondition - The join condition expression.
Throws:
DbException - If something goes wrong.
Method Detail

getDefault

public java.lang.Object getDefault(int index)
                            throws DbException
Returns the default value for the field at the given index.

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

equals

public boolean equals(java.lang.Object o)
Check if an object is equal to the current one.

Overrides:
equals in class DbAbstractTable
Parameters:
o - The object to be compared.
Returns:
true: if these object are equal; false: otherwise.

getDefault

public java.lang.Object getDefault(java.lang.String name)
                            throws DbException
Returns the default value for the field whose name is specified.

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

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 tjhe needed 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 number of columns.

deleter

public DbDeleter deleter()
                  throws DbException
Returns a deleter for deleting rows in the database. This deleter takes care of constraints.

Overrides:
deleter in class DbAbstractTable
Returns:
The DbDeleter object to perform delete operations.
Throws:
DbException - If something goes wrong.

getConstraint

public DbConstraint getConstraint()
Returns the DbConstraint object associated with this table.

Specified by:
getConstraint in class DbAbstractTable
Returns:
The requested DbConstraint.

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 position of the needed column.
Returns:
The column value
Throws:
DbException - If something goes wrong.

inserter

public DbInserter inserter()
                    throws DbException
Return an inserter for inserting new data in the database. This method is for SQL of the form INSERT INTO table(...) VALUES(...) This inserter takes care of constraints.

Overrides:
inserter in class DbAbstractTable
Returns:
The DbInserter object to insert data into the table.
Throws:
DbException - If something goes wrong.

inserter

public DbInserter inserter(DbSelector selector)
                    throws DbException
Return an inserter for inserting new data in the database. This method is for SQL of the form INSERT INTO table(...) SELECT ... This inserter takes care of constraints.

Overrides:
inserter in class DbAbstractTable
Parameters:
selector - The selector to create the DbInserter object.
Returns:
The DbInserter object to insert data into the table.
Throws:
DbException - If something goes wrong.

setTableName

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

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

simpleDeleter

public DbDeleter simpleDeleter()
                        throws DbException
Returns a deleter for deleting rows in the database. This deleter takes care of constraints.

Overrides:
simpleDeleter in class DbAbstractTable
Returns:
The DbDeleter object to perform delete operations.
Throws:
DbException - If something goes wrong.

simpleInserter

public DbInserter simpleInserter()
                          throws DbException
Return an inserter for inserting new data in the database. This method is for SQL of the form INSERT INTO table(...) SELECT ... This inserter DOES NOT take care of constraints.

Overrides:
simpleInserter in class DbAbstractTable
Returns:
The DbInserter object to perform a simple insertion.
Throws:
DbException - If something goes wrong.

simpleInserter

public DbInserter simpleInserter(DbSelector selector)
                          throws DbException
Return an inserter for inserting new data in the database. This method is for SQL of the form INSERT INTO table(...) SELECT ... This inserter DOES NOT take care of constraints.

Overrides:
simpleInserter in class DbAbstractTable
Parameters:
selector - The selector to create the DbInserter object.
Returns:
The DbInserter object to perform a simple insertion.
Throws:
DbException - If something goes wrong.

simpleUpdater

public DbUpdater simpleUpdater()
                        throws DbException
Return an updater for updating rows in the database. This updater DOES NOT take care of constraints.

Overrides:
simpleUpdater in class DbAbstractTable
Returns:
The DbUpdater object to perform update operations.
Throws:
DbException - If something goes wrong.

updater

public DbUpdater updater()
                  throws DbException
Return an updater for updating rows in the database. This updater takes care of constraints.

Overrides:
updater in class DbAbstractTable
Returns:
The DbUpdater object to perform update operations.
Throws:
DbException - If something goes wrong.

usesTables

public void usesTables(java.util.Set c)
Returns the base tables used in this joined table.

Specified by:
usesTables in interface DbTableUser
Overrides:
usesTables in class DbAbstractTable
Parameters:
c - The set in which used tables will be put.