javatools.db
Class DbExpr

java.lang.Object
  |
  +--javatools.db.DbExpr
All Implemented Interfaces:
DbTableUser
Direct Known Subclasses:
DbColumn, DbCriterion, DbExprFuncDef, DbLiteral, DbMiscExpr, DbParenthesis, DbSelector, DbValueList

public abstract class DbExpr
extends java.lang.Object
implements DbTableUser

An sql expression class. This is the abstract base class for any type of SQL expression.


Constructor Summary
DbExpr(DbDatabase db)
          Constructor for the DbExpr object
 
Method Summary
 DbExpr and(DbExpr e)
          Returns an expression created as an "and" between the current expression and another expression.
 DbExpr containsAllStrings(java.util.List values)
          Creates an expression to be used to search in char columns containing one of the specified strings.
 DbExpr containsAllStrings(java.lang.String[] values)
          Creates an expression to be used to search in char columns containing one of the specified strings.
 DbExpr count()
          Returns the count expression for the current expression.
 DbExpr dateTrunc()
          Truncs the date?
 DbCriterion equal(java.lang.Object o)
          Return an expression representing this column being equal to another value.
abstract  java.lang.String getQueryString()
          Any DbExpr needs to be able to convert into the SQL string equivilent.
 DbCriterion greaterThan(java.lang.Object o)
          Return an expression representing this column being greater than another value.
 DbCriterion greaterThanOrEqual(java.lang.Object o)
          Return an expression representing this column being greater than or equal to another value.
 DbCriterion in(java.util.Collection valueList)
          Returns an expression that means "IN (value1, value2, ..., valuen)"
 DbCriterion in(java.lang.Object o)
          Returns an expression to represent the "in" clause.
 DbCriterion isNotNull()
          Gets the notNull attribute of the DbExpr object
 DbCriterion isNull()
          Gets the null attribute of the DbExpr object
 DbCriterion lessThan(java.lang.Object o)
          Return an expression representing this column being less than another value.
 DbCriterion lessThanOrEqual(java.lang.Object o)
          Return an expression representing this column being less than or equal to another value.
 DbCriterion like(java.lang.Object o)
          Return an expression representing this column being LIKE another value.
 DbExpr lower()
          Returns an expression in which it will take the lowercase value for current expression.
 DbExpr max()
          Returns an expression in which it will take the max value for current expression.
 DbExpr min()
          Returns an expression in which it will take the max value for current expression.
 DbCriterion notEqual(java.lang.Object o)
          Return an expression representing this column being equal to another value.
 DbCriterion notIn(java.util.Collection valueList)
          Returns an expression that means "NOT IN (value1, value2, ..., valuen)"
 DbCriterion notIn(java.lang.Object o)
          Returns an expression to represent the "not in" clause.
 DbExpr or(DbExpr e)
          Returns an expression created as an "or" between the current expression and another expression.
abstract  int setSqlValues(java.sql.PreparedStatement ps, int i)
          Any DbExpr needs to be able to substitute any parameters as per JDBC "?"
 DbExpr upper()
          Returns an expression in which it will take the uppercase value for current expression.
 void usesTables(java.util.Set c)
          Adds to the passed set all the tables used by this expression.
static void usesTables(java.util.Set c, java.lang.Object o)
          Adds to the passed set all the tables used by an expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DbExpr

public DbExpr(DbDatabase db)
Constructor for the DbExpr object

Parameters:
db - The database to be used.
Method Detail

usesTables

public static void usesTables(java.util.Set c,
                              java.lang.Object o)
Adds to the passed set all the tables used by an expression.

Parameters:
c - The set to add used tables to.
o - The expression to find tables from.

setSqlValues

public abstract int setSqlValues(java.sql.PreparedStatement ps,
                                 int i)
                          throws DbException,
                                 java.sql.SQLException
Any DbExpr needs to be able to substitute any parameters as per JDBC "?" substitutions.

Parameters:
ps - The PreparedStatement
i - The new sqlValues value
Returns:
An index (obscure).
Throws:
DbException - If something goes wrong.
java.sql.SQLException - If something goes wrong.

getQueryString

public abstract java.lang.String getQueryString()
                                         throws DbException
Any DbExpr needs to be able to convert into the SQL string equivilent.

Returns:
The queryString value
Throws:
DbException - If something goes wrong.

isNull

public DbCriterion isNull()
Gets the null attribute of the DbExpr object

Returns:
The null value

isNotNull

public DbCriterion isNotNull()
Gets the notNull attribute of the DbExpr object

Returns:
The notNull value

usesTables

public void usesTables(java.util.Set c)
Adds to the passed set all the tables used by this expression.

Specified by:
usesTables in interface DbTableUser
Parameters:
c - The set to add tables to.

and

public DbExpr and(DbExpr e)
Returns an expression created as an "and" between the current expression and another expression.

Parameters:
e - The expression with which it will build the "and" expression.
Returns:
The resulting "and" expression.

or

public DbExpr or(DbExpr e)
Returns an expression created as an "or" between the current expression and another expression.

Parameters:
e - The expression with which it will build the "and" expression.
Returns:
The resulting "or" expression.

max

public DbExpr max()
Returns an expression in which it will take the max value for current expression.

Returns:
The expression representing the max value for this expression.

min

public DbExpr min()
Returns an expression in which it will take the max value for current expression.

Returns:
The expression representing the max value for this expression.

upper

public DbExpr upper()
Returns an expression in which it will take the uppercase value for current expression.

Returns:
The uppercase for this expression.

lower

public DbExpr lower()
Returns an expression in which it will take the lowercase value for current expression.

Returns:
The lowercase for this expression.

count

public DbExpr count()
Returns the count expression for the current expression. It is effective only with a DbLiteral expression, containing "*".

Returns:
The expression containing the count for the current expression.

dateTrunc

public DbExpr dateTrunc()
                 throws DbException
Truncs the date? Obscure.

Returns:
The final expression.
Throws:
DbException - If something goes wrong.

equal

public DbCriterion equal(java.lang.Object o)
Return an expression representing this column being equal to another value.

Parameters:
o - The object that the current expression should be equal to.
Returns:
The final expression.

notEqual

public DbCriterion notEqual(java.lang.Object o)
Return an expression representing this column being equal to another value.

Parameters:
o - The object that the current expression should be not equal to.
Returns:
The final expression.

like

public DbCriterion like(java.lang.Object o)
Return an expression representing this column being LIKE another value.

Parameters:
o - The object that the current expression should be LIKE.
Returns:
The final expression.

containsAllStrings

public DbExpr containsAllStrings(java.lang.String[] values)
Creates an expression to be used to search in char columns containing one of the specified strings.

Parameters:
values - The array of strings.
Returns:
The needed expression.

containsAllStrings

public DbExpr containsAllStrings(java.util.List values)
Creates an expression to be used to search in char columns containing one of the specified strings.

Parameters:
values - The list of strings.
Returns:
The needed expression.

greaterThan

public DbCriterion greaterThan(java.lang.Object o)
Return an expression representing this column being greater than another value.

Parameters:
o - The object that the current expression should be greater than.
Returns:
The final expression.

greaterThanOrEqual

public DbCriterion greaterThanOrEqual(java.lang.Object o)
Return an expression representing this column being greater than or equal to another value.

Parameters:
o - The object that the current expression should be greater than or equal.
Returns:
The final expression.

lessThan

public DbCriterion lessThan(java.lang.Object o)
Return an expression representing this column being less than another value.

Parameters:
o - The object that the current expression should be less than.
Returns:
The final expression.

lessThanOrEqual

public DbCriterion lessThanOrEqual(java.lang.Object o)
Return an expression representing this column being less than or equal to another value.

Parameters:
o - The object that the current expression should be less than or equal.
Returns:
The final expression.

in

public DbCriterion in(java.lang.Object o)
Returns an expression to represent the "in" clause.

Parameters:
o - The object representing usually the selector in which the expression should find its values.
Returns:
The final expression.

in

public DbCriterion in(java.util.Collection valueList)
Returns an expression that means "IN (value1, value2, ..., valuen)"

Parameters:
valueList - The value list.
Returns:
The needed expression.

notIn

public DbCriterion notIn(java.lang.Object o)
Returns an expression to represent the "not in" clause.

Parameters:
o - The object representing usually the selector in which the expression should NOT find its values.
Returns:
The final expression.

notIn

public DbCriterion notIn(java.util.Collection valueList)
Returns an expression that means "NOT IN (value1, value2, ..., valuen)"

Parameters:
valueList - The list of values.
Returns:
The needed expression