|
|||||||||
| Home >> All >> org >> apache >> torque >> [ util overview ] | PREV CLASS NEXT CLASS | ||||||||
SUMMARY: JAVADOC | SOURCE | DOWNLOAD | NESTED | FIELD | CONSTR | METHOD |
DETAIL: FIELD | CONSTR | METHOD | ||||||||
org.apache.torque.util
Class Criteria

java.lang.Objectjava.util.Dictionary
java.util.Hashtable
org.apache.torque.util.Criteria
- All Implemented Interfaces:
- java.lang.Cloneable, java.util.Map, java.io.Serializable
- public class Criteria
- extends java.util.Hashtable
This is a utility class that is used for retrieving different types of values from a hashtable based on a simple name string. This class is meant to minimize the amount of casting that needs to be done when working with Hashtables. NOTE: other methods will be added as needed and as time permits.
- Version:
- $Id: Criteria.java,v 1.42.2.3 2004/05/20 04:36:06 seade Exp $
| Nested Class Summary | |
class |
Criteria.Criterion
This is an inner class that describes an object in the criteria. |
| Nested classes inherited from class java.util.Hashtable |
|
| Nested classes inherited from class java.util.Map |
java.util.Map.Entry |
| Field Summary | |
private java.util.HashMap |
aliases
|
static SqlEnum |
ALL
Comparison type. |
static SqlEnum |
ALT_NOT_EQUAL
Comparison type. |
private static SqlEnum |
ASC
"Order by" qualifier - ascending |
private java.util.Hashtable |
asColumns
|
private boolean |
cascade
|
static SqlEnum |
CURRENT_DATE
"CURRENT_DATE" ANSI SQL function |
static SqlEnum |
CURRENT_TIME
"CURRENT_TIME" ANSI SQL function |
static SqlEnum |
CUSTOM
Comparison type. |
private java.lang.String |
dbName
The name of the database. |
private static int |
DEFAULT_CAPACITY
|
private static SqlEnum |
DESC
"Order by" qualifier - descending |
static SqlEnum |
DISTINCT
Comparison type. |
static SqlEnum |
EQUAL
Comparison type. |
static SqlEnum |
GREATER_EQUAL
Comparison type. |
static SqlEnum |
GREATER_THAN
Comparison type. |
private UniqueList |
groupByColumns
|
private Criteria.Criterion |
having
|
private boolean |
ignoreCase
|
static SqlEnum |
ILIKE
Comparison type. |
static SqlEnum |
IN
Comparison type. |
static SqlEnum |
ISNOTNULL
"IS NOT NULL" null comparison |
static SqlEnum |
ISNULL
"IS NULL" null comparison |
static SqlEnum |
JOIN
Comparison type. |
private java.util.ArrayList |
joinL
|
private java.util.ArrayList |
joinR
|
static SqlEnum |
LESS_EQUAL
Comparison type. |
static SqlEnum |
LESS_THAN
Comparison type. |
static SqlEnum |
LIKE
Comparison type. |
private int |
limit
To limit the number of rows to return. |
private static org.apache.commons.logging.Log |
log
the log. |
static SqlEnum |
NOT_EQUAL
Comparison type. |
static SqlEnum |
NOT_ILIKE
Comparison type. |
static SqlEnum |
NOT_IN
Comparison type. |
static SqlEnum |
NOT_LIKE
Comparison type. |
private int |
offset
To start the results at a row other than the first one. |
private UniqueList |
orderByColumns
|
private java.lang.String |
originalDbName
The name of the database as given in the contructor. |
private UniqueList |
selectColumns
|
private UniqueList |
selectModifiers
|
private boolean |
singleRecord
|
private boolean |
useTransaction
|
| Fields inherited from class java.util.Hashtable |
|
| Constructor Summary | |
Criteria()
Creates a new instance with the default capacity. |
|
Criteria(int initialCapacity)
Creates a new instance with the specified capacity. |
|
Criteria(java.lang.String dbName)
Creates a new instance with the default capacity which corresponds to the specified database. |
|
Criteria(java.lang.String dbName,
int initialCapacity)
Creates a new instance with the specified capacity which corresponds to the specified database. |
|
| Method Summary | |
Criteria |
add(Criteria.Criterion c)
This method adds a prepared Criterion object to the Criteria. |
Criteria |
add(java.lang.String column,
boolean value)
Convenience method to add a boolean to Criteria. |
Criteria |
add(java.lang.String column,
boolean value,
SqlEnum comparison)
Convenience method to add a boolean to Criteria. |
Criteria |
add(java.lang.String column,
double value)
Convenience method to add a double to Criteria. |
Criteria |
add(java.lang.String column,
double value,
SqlEnum comparison)
Convenience method to add a double to Criteria. |
Criteria |
add(java.lang.String column,
float value)
Convenience method to add a float to Criteria. |
Criteria |
add(java.lang.String column,
float value,
SqlEnum comparison)
Convenience method to add a float to Criteria. |
Criteria |
add(java.lang.String column,
int value)
Convenience method to add an int to Criteria. |
Criteria |
add(java.lang.String column,
int value,
SqlEnum comparison)
Convenience method to add an int to Criteria. |
Criteria |
add(java.lang.String column,
long value)
Convenience method to add a long to Criteria. |
Criteria |
add(java.lang.String column,
long value,
SqlEnum comparison)
Convenience method to add a long to Criteria. |
Criteria |
add(java.lang.String column,
java.lang.Object value)
This method adds a new criterion to the list of criterias. |
Criteria |
add(java.lang.String column,
java.lang.Object value,
SqlEnum comparison)
This method adds a new criterion to the list of criterias. |
Criteria |
add(java.lang.String table,
java.lang.String column,
java.lang.Object value)
This method adds a new criterion to the list of criterias. |
Criteria |
add(java.lang.String table,
java.lang.String column,
java.lang.Object value,
SqlEnum comparison)
This method adds a new criterion to the list of criterias. |
void |
addAlias(java.lang.String alias,
java.lang.String table)
Allows one to specify an alias for a table that can be used in various parts of the SQL. |
Criteria |
addAscendingOrderByColumn(java.lang.String name)
Add order by column name, explicitly specifying ascending. |
Criteria |
addAsColumn(java.lang.String name,
java.lang.String clause)
Add an AS clause to the select columns. |
Criteria |
addDate(java.lang.String column,
int year,
int month,
int date)
Convenience method to add a Date object specified by year, month, and date into the Criteria. |
Criteria |
addDate(java.lang.String column,
int year,
int month,
int date,
SqlEnum comparison)
Convenience method to add a Date object specified by year, month, and date into the Criteria. |
Criteria |
addDescendingOrderByColumn(java.lang.String name)
Add order by column name, explicitly specifying descending. |
Criteria |
addGroupByColumn(java.lang.String groupBy)
Add group by column name. |
Criteria |
addHaving(Criteria.Criterion having)
This method adds a prepared Criterion object to the Criteria as a having clause. |
Criteria |
addIn(java.lang.String column,
int[] values)
Adds an 'IN' clause with the criteria supplied as an int array. |
Criteria |
addIn(java.lang.String column,
java.util.List values)
Adds an 'IN' clause with the criteria supplied as a List. |
Criteria |
addIn(java.lang.String column,
java.lang.Object[] values)
Adds an 'IN' clause with the criteria supplied as an Object array. |
Criteria |
addJoin(java.lang.String left,
java.lang.String right)
This is the way that you should add a join of two tables. |
Criteria |
addNotIn(java.lang.String column,
int[] values)
Adds a 'NOT IN' clause with the criteria supplied as an int array. |
Criteria |
addNotIn(java.lang.String column,
java.util.List values)
Adds a 'NOT IN' clause with the criteria supplied as a List. |
Criteria |
addNotIn(java.lang.String column,
java.lang.Object[] values)
Adds a 'NOT IN' clause with the criteria supplied as an Object array. |
Criteria |
addSelectColumn(java.lang.String name)
Add select column. |
Criteria |
and(Criteria.Criterion c)
This method adds a prepared Criterion object to the Criteria. |
Criteria |
and(java.lang.String column,
boolean value)
Convenience method to add a boolean to Criteria. |
Criteria |
and(java.lang.String column,
boolean value,
SqlEnum comparison)
Convenience method to add a boolean to Criteria. |
Criteria |
and(java.lang.String column,
double value)
Convenience method to add a double to Criteria. |
Criteria |
and(java.lang.String column,
double value,
SqlEnum comparison)
Convenience method to add a double to Criteria. |
Criteria |
and(java.lang.String column,
float value)
Convenience method to add a float to Criteria. |
Criteria |
and(java.lang.String column,
float value,
SqlEnum comparison)
Convenience method to add a float to Criteria. |
Criteria |
and(java.lang.String column,
int value)
Convenience method to add an int to Criteria. |
Criteria |
and(java.lang.String column,
int value,
SqlEnum comparison)
Convenience method to add an int to Criteria. |
Criteria |
and(java.lang.String column,
long value)
Convenience method to add a long to Criteria. |
Criteria |
and(java.lang.String column,
long value,
SqlEnum comparison)
Convenience method to add a long to Criteria. |
Criteria |
and(java.lang.String column,
java.lang.Object value)
This method adds a new criterion to the list of criterias. |
Criteria |
and(java.lang.String column,
java.lang.Object value,
SqlEnum comparison)
This method adds a new criterion to the list of criterias. |
Criteria |
and(java.lang.String table,
java.lang.String column,
java.lang.Object value)
This method adds a new criterion to the list of criterias. |
Criteria |
and(java.lang.String table,
java.lang.String column,
java.lang.Object value,
SqlEnum comparison)
This method adds a new criterion to the list of criterias. |
Criteria |
andDate(java.lang.String column,
int year,
int month,
int date)
Convenience method to add a Date object specified by year, month, and date into the Criteria. |
Criteria |
andDate(java.lang.String column,
int year,
int month,
int date,
SqlEnum comparison)
Convenience method to add a Date object specified by year, month, and date into the Criteria. |
Criteria |
andIn(java.lang.String column,
int[] values)
Adds an 'IN' clause with the criteria supplied as an int array. |
Criteria |
andIn(java.lang.String column,
java.util.List values)
Adds an 'IN' clause with the criteria supplied as a List. |
Criteria |
andIn(java.lang.String column,
java.lang.Object[] values)
Adds an 'IN' clause with the criteria supplied as an Object array. |
Criteria |
andNotIn(java.lang.String column,
int[] values)
Adds a 'NOT IN' clause with the criteria supplied as an int array. |
Criteria |
andNotIn(java.lang.String column,
java.util.List values)
Adds a 'NOT IN' clause with the criteria supplied as a List. |
Criteria |
andNotIn(java.lang.String column,
java.lang.Object[] values)
Adds a 'NOT IN' clause with the criteria supplied as an Object array. |
void |
clear()
Brings this criteria back to its initial state, so that it can be reused as if it was new. |
boolean |
containsKey(java.lang.String table,
java.lang.String column)
Does this Criteria Object contain the specified key? |
boolean |
equals(java.lang.Object crit)
This method checks another Criteria to see if they contain the same attributes and hashtable entries. |
java.lang.Object |
get(java.lang.Object key)
Overrides Hashtable get, so that the value placed in the Criterion is returned instead of the Criterion. |
java.util.Hashtable |
getAsColumns()
Get the column aliases. |
java.math.BigDecimal |
getBigDecimal(java.lang.String name)
Convenience method to return a BigDecimal. |
java.math.BigDecimal |
getBigDecimal(java.lang.String table,
java.lang.String column)
Convenience method to return a BigDecimal. |
boolean |
getBoolean(java.lang.String column)
Convenience method to return value as a boolean. |
boolean |
getBoolean(java.lang.String table,
java.lang.String column)
Convenience method to return value as a boolean. |
java.lang.String |
getColumnName(java.lang.String name)
Method to return a String table name. |
SqlEnum |
getComparison(java.lang.String key)
Method to return a comparison String. |
SqlEnum |
getComparison(java.lang.String table,
java.lang.String column)
Method to return a comparison String. |
Criteria.Criterion |
getCriterion(java.lang.String column)
Method to return criteria related to columns in a table. |
Criteria.Criterion |
getCriterion(java.lang.String table,
java.lang.String column)
Method to return criteria related to a column in a table. |
java.util.Date |
getDate(java.lang.String name)
Convenience method to return a Date. |
java.util.Date |
getDate(java.lang.String table,
java.lang.String column)
Convenience method to return a Date. |
java.lang.String |
getDbName()
Get the Database(Map) name. |
double |
getDouble(java.lang.String name)
Convenience method to return a double. |
double |
getDouble(java.lang.String table,
java.lang.String column)
Convenience method to return a double. |
float |
getFloat(java.lang.String name)
Convenience method to return a float. |
float |
getFloat(java.lang.String table,
java.lang.String column)
Convenience method to return a float. |
UniqueList |
getGroupByColumns()
Get group by columns. |
Criteria.Criterion |
getHaving()
Get Having Criterion. |
int |
getInt(java.lang.String name)
Convenience method to return an int. |
int |
getInt(java.lang.String table,
java.lang.String column)
Convenience method to return an int. |
java.lang.Integer |
getInteger(java.lang.String name)
Convenience method to return an Integer. |
java.lang.Integer |
getInteger(java.lang.String table,
java.lang.String column)
Convenience method to return an Integer. |
java.util.List |
getJoinL()
get one side of the set of possible joins. |
java.util.List |
getJoinR()
get one side of the set of possible joins. |
int |
getLimit()
Get limit. |
java.util.List |
getList(java.lang.String name)
Convenience method to return a List. |
java.util.List |
getList(java.lang.String table,
java.lang.String column)
Convenience method to return a List. |
long |
getLong(java.lang.String name)
Convenience method to return a long. |
long |
getLong(java.lang.String table,
java.lang.String column)
Convenience method to return a long. |
Criteria.Criterion |
getNewCriterion(java.lang.String column,
java.lang.Object value,
SqlEnum comparison)
Method to return criterion that is not added automatically to this Criteria. |
Criteria.Criterion |
getNewCriterion(java.lang.String table,
java.lang.String column,
java.lang.Object value,
SqlEnum comparison)
Method to return criterion that is not added automatically to this Criteria. |
org.apache.torque.om.ObjectKey |
getObjectKey(java.lang.String name)
Convenience method to return an ObjectKey. |
org.apache.torque.om.ObjectKey |
getObjectKey(java.lang.String table,
java.lang.String column)
Convenience method to return an ObjectKey. |
int |
getOffset()
Get offset. |
UniqueList |
getOrderByColumns()
Get order by columns. |
UniqueList |
getSelectColumns()
Get select columns. |
UniqueList |
getSelectModifiers()
Get select modifiers. |
java.lang.String |
getString(java.lang.String name)
Convenience method to return a String. |
java.lang.String |
getString(java.lang.String table,
java.lang.String column)
Convenience method to return a String. |
java.lang.String |
getTableForAlias(java.lang.String alias)
Returns the table name associated with an alias. |
java.lang.String |
getTableName(java.lang.String name)
Method to return a String table name. |
java.lang.Object |
getValue(java.lang.String name)
Method to return the value that was added to Criteria. |
java.lang.Object |
getValue(java.lang.String table,
java.lang.String column)
Method to return the value that was added to Criteria. |
boolean |
isCascade()
Is cascade set? |
boolean |
isIgnoreCase()
Is ignore case on or off? |
boolean |
isSingleRecord()
Is single record? |
protected boolean |
isUseTransaction()
called by BasePeer to determine whether the sql command specified by this criteria must be wrapped in a transaction. |
Criteria |
or(Criteria.Criterion c)
This method adds a prepared Criterion object to the Criteria. |
Criteria |
or(java.lang.String column,
boolean value)
Convenience method to add a boolean to Criteria. |
Criteria |
or(java.lang.String column,
boolean value,
SqlEnum comparison)
Convenience method to add a boolean to Criteria. |
Criteria |
or(java.lang.String column,
double value)
Convenience method to add a double to Criteria. |
Criteria |
or(java.lang.String column,
double value,
SqlEnum comparison)
Convenience method to add a double to Criteria. |
Criteria |
or(java.lang.String column,
float value)
Convenience method to add a float to Criteria. |
Criteria |
or(java.lang.String column,
float value,
SqlEnum comparison)
Convenience method to add a float to Criteria. |
Criteria |
or(java.lang.String column,
int value)
Convenience method to add an int to Criteria. |
Criteria |
or(java.lang.String column,
int value,
SqlEnum comparison)
Convenience method to add an int to Criteria. |
Criteria |
or(java.lang.String column,
long value)
Convenience method to add a long to Criteria. |
Criteria |
or(java.lang.String column,
long value,
SqlEnum comparison)
Convenience method to add a long to Criteria. |
Criteria |
or(java.lang.String column,
java.lang.Object value)
This method adds a new criterion to the list of criterias. |
Criteria |
or(java.lang.String column,
java.lang.Object value,
SqlEnum comparison)
This method adds a new criterion to the list of criterias. |
Criteria |
or(java.lang.String table,
java.lang.String column,
java.lang.Object value)
This method adds a new criterion to the list of criterias. |
Criteria |
or(java.lang.String table,
java.lang.String column,
java.lang.Object value,
SqlEnum comparison)
This method adds a new criterion to the list of criterias. |
Criteria |
orDate(java.lang.String column,
int year,
int month,
int date)
Convenience method to add a Date object specified by year, month, and date into the Criteria. |
Criteria |
orDate(java.lang.String column,
int year,
int month,
int date,
SqlEnum comparison)
Convenience method to add a Date object specified by year, month, and date into the Criteria. |
Criteria |
orIn(java.lang.String column,
int[] values)
Adds an 'IN' clause with the criteria supplied as an int array. |
Criteria |
orIn(java.lang.String column,
java.util.List values)
Adds an 'IN' clause with the criteria supplied as a List. |
Criteria |
orIn(java.lang.String column,
java.lang.Object[] values)
Adds an 'IN' clause with the criteria supplied as an Object array. |
Criteria |
orNotIn(java.lang.String column,
int[] values)
Adds a 'NOT IN' clause with the criteria supplied as an int array. |
Criteria |
orNotIn(java.lang.String column,
java.util.List values)
Adds a 'NOT IN' clause with the criteria supplied as a List. |
Criteria |
orNotIn(java.lang.String column,
java.lang.Object[] values)
Adds a 'NOT IN' clause with the criteria supplied as an Object array. |
java.lang.Object |
put(java.lang.Object key,
java.lang.Object value)
Overrides Hashtable put, so that this object is returned instead of the value previously in the Criteria object. |
void |
putAll(java.util.Map t)
Copies all of the mappings from the specified Map to this Criteria These mappings will replace any mappings that this Criteria had for any of the keys currently in the specified Map. |
java.lang.Object |
remove(java.lang.String key)
Remove an object from the criteria. |
void |
setAll()
Adds "ALL " to the SQL statement. |
void |
setBlobFlag(boolean b)
Deprecated. this flag is not used any longer |
Criteria |
setCascade(boolean b)
Set cascade. |
void |
setDbName(java.lang.String dbName)
Set the DatabaseMap name. |
void |
setDistinct()
Adds "DISTINCT " to the SQL statement. |
Criteria |
setIgnoreCase(boolean b)
Sets ignore case. |
Criteria |
setLimit(int limit)
Set limit. |
Criteria |
setOffset(int offset)
Set offset. |
Criteria |
setSingleRecord(boolean b)
Set single record? Set this to true if you expect the query
to result in only a single result record (the default behaviour is to
throw a TorqueException if multiple records are returned when the query
is executed). |
void |
setUseTransaction(boolean v)
Will force the sql represented by this criteria to be executed within a transaction. |
java.lang.String |
toString()
Build a string representation of the Criteria. |
| Methods inherited from class java.util.Hashtable |
clone, contains, containsKey, containsValue, elements, entrySet, hashCode, isEmpty, keys, keySet, rehash, remove, size, values |
| Methods inherited from class java.lang.Object |
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Field Detail |
EQUAL
public static final SqlEnum EQUAL
- Comparison type.
NOT_EQUAL
public static final SqlEnum NOT_EQUAL
- Comparison type.
ALT_NOT_EQUAL
public static final SqlEnum ALT_NOT_EQUAL
- Comparison type.
GREATER_THAN
public static final SqlEnum GREATER_THAN
- Comparison type.
LESS_THAN
public static final SqlEnum LESS_THAN
- Comparison type.
GREATER_EQUAL
public static final SqlEnum GREATER_EQUAL
- Comparison type.
LESS_EQUAL
public static final SqlEnum LESS_EQUAL
- Comparison type.
LIKE
public static final SqlEnum LIKE
- Comparison type.
NOT_LIKE
public static final SqlEnum NOT_LIKE
- Comparison type.
ILIKE
public static final SqlEnum ILIKE
- Comparison type.
NOT_ILIKE
public static final SqlEnum NOT_ILIKE
- Comparison type.
CUSTOM
public static final SqlEnum CUSTOM
- Comparison type.
DISTINCT
public static final SqlEnum DISTINCT
- Comparison type.
IN
public static final SqlEnum IN
- Comparison type.
NOT_IN
public static final SqlEnum NOT_IN
- Comparison type.
ALL
public static final SqlEnum ALL
- Comparison type.
JOIN
public static final SqlEnum JOIN
- Comparison type.
ASC
private static final SqlEnum ASC
- "Order by" qualifier - ascending
DESC
private static final SqlEnum DESC
- "Order by" qualifier - descending
ISNULL
public static final SqlEnum ISNULL
- "IS NULL" null comparison
ISNOTNULL
public static final SqlEnum ISNOTNULL
- "IS NOT NULL" null comparison
CURRENT_DATE
public static final SqlEnum CURRENT_DATE
- "CURRENT_DATE" ANSI SQL function
CURRENT_TIME
public static final SqlEnum CURRENT_TIME
- "CURRENT_TIME" ANSI SQL function
DEFAULT_CAPACITY
private static final int DEFAULT_CAPACITY
- See Also:
- Constant Field Values
ignoreCase
private boolean ignoreCase
singleRecord
private boolean singleRecord
cascade
private boolean cascade
selectModifiers
private UniqueList selectModifiers
selectColumns
private UniqueList selectColumns
orderByColumns
private UniqueList orderByColumns
groupByColumns
private UniqueList groupByColumns
having
private Criteria.Criterion having
asColumns
private java.util.Hashtable asColumns
joinL
private java.util.ArrayList joinL
joinR
private java.util.ArrayList joinR
dbName
private java.lang.String dbName
- The name of the database.
originalDbName
private java.lang.String originalDbName
- The name of the database as given in the contructor.
limit
private int limit
- To limit the number of rows to return.
-1means return all rows.
offset
private int offset
- To start the results at a row other than the first one.
aliases
private java.util.HashMap aliases
useTransaction
private boolean useTransaction
log
private static org.apache.commons.logging.Log log
- the log.
| Constructor Detail |
Criteria
public Criteria()
- Creates a new instance with the default capacity.
Criteria
public Criteria(int initialCapacity)
- Creates a new instance with the specified capacity.
Criteria
public Criteria(java.lang.String dbName)
- Creates a new instance with the default capacity which corresponds to
the specified database.
Criteria
public Criteria(java.lang.String dbName, int initialCapacity)
- Creates a new instance with the specified capacity which corresponds to
the specified database.
| Method Detail |
clear
public void clear()
- Brings this criteria back to its initial state, so that it
can be reused as if it was new. Except if the criteria has grown in
capacity, it is left at the current capacity.
addAsColumn
public Criteria addAsColumn(java.lang.String name, java.lang.String clause)
- Add an AS clause to the select columns. Usage:
Criteria myCrit = new Criteria(); myCrit.addAsColumn("alias", "ALIAS("+MyPeer.ID+")");
getAsColumns
public java.util.Hashtable getAsColumns()
- Get the column aliases.
addAlias
public void addAlias(java.lang.String alias, java.lang.String table)
- Allows one to specify an alias for a table that can
be used in various parts of the SQL.
getTableForAlias
public java.lang.String getTableForAlias(java.lang.String alias)
- Returns the table name associated with an alias.
containsKey
public boolean containsKey(java.lang.String table, java.lang.String column)
- Does this Criteria Object contain the specified key?
getBoolean
public boolean getBoolean(java.lang.String column)
- Convenience method to return value as a boolean.
<
JAVADOC