|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object toolbox.dao.Query
public class Query
Class that generates SQL query strings in Java prepared statement format.
The Query object is initialised with a prefix and postfix to be used in the generation of the query. Fields to be queried on are added to the object as name/value pairs.
The accessor method getSQL()
returns the query string formatted
in Java prepared statement format.
The accessor method getValues()
returns an object array of the
field values of the query object.
Nested Class Summary | |
---|---|
(package private) class |
Query.Field
The Field class represents a field within the query being generated. |
Field Summary | |
---|---|
static java.lang.String |
EQUALS
Equals operator (=). |
static java.lang.String |
GREATER_EQUALS
Greater than or equals operator (>=). |
static java.lang.String |
LESS_EQUALS
Less than or equals operator (<=). |
static java.lang.String |
LIKE
Like operator. |
static java.lang.String |
NOT_EQUALS
Not equals operator (!=). |
static java.lang.String |
RANGE
Specifies a range (x >= y1 and x <= y2). |
Constructor Summary | |
---|---|
Query()
Default constructor |
|
Query(java.lang.String prefix,
java.lang.String postfix)
Creates a new Query object with the given database table name and additional information that must be added to the generated query e.g order by clauses. |
Method Summary | |
---|---|
void |
addField(java.lang.String name,
java.lang.String type,
java.lang.Object[] values)
Adds a field to the query object. |
java.lang.String |
getSQL()
Generates a SQL query in Java prepared statement format. |
java.lang.Object[] |
getValues()
Returns an Object array of field values contained in this query object. |
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 LIKE
public static final java.lang.String RANGE
Constructor Detail |
---|
public Query()
public Query(java.lang.String prefix, java.lang.String postfix)
prefix
- Use this prefix instead of select *postfix
- Additional information to add on to the generated query.Method Detail |
---|
public void addField(java.lang.String name, java.lang.String type, java.lang.Object[] values)
name
- Name of the field to add.type
- Type of the field to add: single or range.values
- Values of the field to add.public java.lang.String getSQL()
public java.lang.Object[] getValues()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |