| 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||

java.lang.Objecttoolbox.dao.PreparedQuery
public class PreparedQuery
Convenience helper class to generate SQL queries in Java 
 PreparedStatement format. This class aims to be a more 
 complete implementation than the current Query class provided
 by this package.
 
 This class provides mutators to add and and or clauses to the
 query. These mutators are implemented in the and(..) and 
 or(..) methods.
 
 The getSQL(..) method returns a String in the Java
 PreparedStatement format and the getValuesAs..() 
 methods return the field values of the query.
 
Please note that this class is not thread safe and calling the and and or methods from multiple threads will result in a corrupt reference.
| Field Summary | |
|---|---|
static java.lang.String | 
EQUALS
The equals operator (=).  | 
static java.lang.String | 
GREATER
The greater than (>) operator.  | 
static java.lang.String | 
GREATER_EQUALS
The greater than or equals (>=) operator.  | 
static java.lang.String | 
IN
The in operator.  | 
static java.lang.String | 
LESS
The less than (<) operator.  | 
static java.lang.String | 
LESS_EQUALS
The less than or equals (<=) operator.  | 
static java.lang.String | 
LIKE
The like operator.  | 
static java.lang.String | 
NOT_EQUALS
The not equals (!=) operator.  | 
static java.lang.String | 
NOT_LIKE
The not like operator.  | 
| Constructor Summary | |
|---|---|
PreparedQuery()
Default constructor.  | 
|
| Method Summary | |
|---|---|
 void | 
and(PreparedQuery query)
Add an and clause to this query.  | 
 void | 
and(java.lang.String field,
    java.lang.String op,
    java.lang.Object val)
Add an and clause to this query.  | 
 java.lang.String | 
getSQL(java.lang.String prefix,
       java.lang.String postfix)
Return the SQL representation of this query as a String in Java PreparedStatement format. | 
 java.lang.Object[] | 
getValuesAsArray()
Return the values of this query as an Object array.  | 
 java.util.List | 
getValuesAsList()
Return the values of this query as a List.  | 
 void | 
or(PreparedQuery query)
Add an or clause to this query.  | 
 void | 
or(java.lang.String field,
   java.lang.String op,
   java.lang.Object val)
Add an or clause to this query.  | 
 void | 
reset()
Reset the internal buffer and values List.  | 
| Methods inherited from class java.lang.Object | 
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait | 
| Field Detail | 
|---|
public static final java.lang.String EQUALS
public static final java.lang.String NOT_EQUALS
public static final java.lang.String LESS_EQUALS
public static final java.lang.String GREATER_EQUALS
public static final java.lang.String LESS
public static final java.lang.String GREATER
public static final java.lang.String LIKE
public static final java.lang.String NOT_LIKE
public static final java.lang.String IN
| Constructor Detail | 
|---|
public PreparedQuery()
| Method Detail | 
|---|
public void reset()
public void and(java.lang.String field,
                java.lang.String op,
                java.lang.Object val)
         throws DaoException
field - String containing the field name to add.op - String containing the name of the operator to use.val - Object containing the value to use in the clause.
DaoException - if the given operator name is invalid.
public void or(java.lang.String field,
               java.lang.String op,
               java.lang.Object val)
        throws DaoException
field - String containing the field name to add.op - String containing the name of the operator to use.val - Object containing the value to use in the clause.
DaoException - if the given operator name is invalid.
public void and(PreparedQuery query)
         throws DaoException
 The provided PreparedQuery's SQL string and values will be
 appended to this query and placed within parenthesis. 
 
query - PreparedQuery that must be appended to this query.
DaoException - if the provide query is invalid.
public void or(PreparedQuery query)
        throws DaoException
 The provided PreparedQuery's SQL string and values will be
 appended to this query and placed within parenthesis. 
 
query - PreparedQuery that must be appended to this query.
DaoException - if the provide query is invalid.
public java.lang.String getSQL(java.lang.String prefix,
                               java.lang.String postfix)
                        throws DaoException
PreparedStatement format.
prefix - String containing a prefix for the generated query. May be
                  null.postfix - String containing a postfix for the generated query.
                  May be null.
DaoException - if the generated query string is invalid.public java.util.List getValuesAsList()
public java.lang.Object[] getValuesAsArray()
  | 
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||