javatools.db
Class DbColumn

java.lang.Object
  |
  +--javatools.db.DbExpr
        |
        +--javatools.db.DbColumn
All Implemented Interfaces:
DbTableUser

public class DbColumn
extends DbExpr

A class that represents a particular column within a particular DbTable. Based upon class DbColumn by Chris Bitmead.


Constructor Summary
DbColumn(DbAbstractTable table, int index)
          Creates a new DbColumn.
 
Method Summary
 boolean equals(java.lang.Object o)
          Checks if a column equals another column.
 int getIndex()
          Returns the index of the column among the fields of the table.
 java.lang.String getName()
          Returns the column name.
 java.lang.String getQueryString()
          Returns the query string related to this column.
 int getSize()
          Returns the display size of this column.
 DbExpr getSubExpr(DbColumn[] cols)
          Currently unused.
 int setSqlValues(java.sql.PreparedStatement ps, int i)
          Sets, in a prepared statement, the value related to this column, that will be used, e.g., in an INSERT operation.
 DbExpr substituteColumn(DbColumn oldCol, DbColumn newCol)
          Currently unused.
 java.lang.String toString()
          The fully qualified name of this column.
 void usesTables(java.util.Set c)
          Adds to the set, the currently indexed table.
 
Methods inherited from class javatools.db.DbExpr
and, containsAllStrings, containsAllStrings, count, dateTrunc, equal, greaterThan, greaterThanOrEqual, in, in, isNotNull, isNull, lessThan, lessThanOrEqual, like, lower, max, min, notEqual, notIn, notIn, or, upper, usesTables
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DbColumn

public DbColumn(DbAbstractTable table,
                int index)
Creates a new DbColumn.

Parameters:
table - The table to get the column from.
index - The position of table's field.
Method Detail

getQueryString

public java.lang.String getQueryString()
Returns the query string related to this column.

Specified by:
getQueryString in class DbExpr
Returns:
The needed string.

getName

public java.lang.String getName()
Returns the column name.

Returns:
The name of this column.

setSqlValues

public int setSqlValues(java.sql.PreparedStatement ps,
                        int i)
                 throws DbException
Sets, in a prepared statement, the value related to this column, that will be used, e.g., in an INSERT operation. Anyway it is obscure...

Specified by:
setSqlValues in class DbExpr
Parameters:
ps - The prepared statement.
i - The index.
Returns:
An index.
Throws:
DbException - If something goes wrong.

getSize

public int getSize()
Returns the display size of this column.

Returns:
The needed display size of the column.

getIndex

public int getIndex()
Returns the index of the column among the fields of the table.

Returns:
The index of the column.

equals

public boolean equals(java.lang.Object o)
Checks if a column equals another column.

Overrides:
equals in class java.lang.Object
Parameters:
o - The object to compare to.
Returns:
true: if it is equal; false: otherwise.

toString

public java.lang.String toString()
The fully qualified name of this column.

Overrides:
toString in class java.lang.Object
Returns:
The name of the column.

usesTables

public void usesTables(java.util.Set c)
Adds to the set, the currently indexed table.

Specified by:
usesTables in interface DbTableUser
Overrides:
usesTables in class DbExpr
Parameters:
c - The set to add current column to.

getSubExpr

public DbExpr getSubExpr(DbColumn[] cols)
                  throws DbException
Currently unused. It should take a sub-expression containing the specified columns.

Parameters:
cols - An array of columns. Only specified columns are taken in the result.
Returns:
The column itself if it is in the list, null otherwise.
Throws:
DbException - If something goes wrong.

substituteColumn

public DbExpr substituteColumn(DbColumn oldCol,
                               DbColumn newCol)
                        throws DbException
Currently unused. It should replace oldCol with newCol.

Parameters:
oldCol - The column to be replaced.
newCol - The column to put.
Returns:
newCol if this column represents oldCol, this column otherwise.
Throws:
DbException - If something goes wrong.