| java.lang.Object org.apache.ojb.broker.query.Criteria
Criteria | public class Criteria implements java.io.Serializable(Code) | | Persistent Criteria can be used to retrieve sets of objects based on their attributes
Normally each attribute is ANDed together, an OR can be performed by creating a new
PersistentCriteria and adding it.
Criteria are used, rather than a simple string, because they can be precompiled for
efficiency.
This code is based on stuff from
COBRA - Java Object Persistence Layer
Copyright (C) 1997, 1998 DB Harvey-George
eMail: cobra@lowrent.org
author: Jakob Braeuchi version: $Id: Criteria.java,v 1.45.2.5 2005/12/21 22:27:09 tomdz Exp $ |
Method Summary | |
protected List | _getGroupby() | protected List | _getOrderby() | public void | addAndCriteria(Criteria pc) | public void | addBetween(Object attribute, Object value1, Object value2) | public void | addColumnEqualTo(String column, Object value) | public void | addColumnEqualToField(String column, Object fieldName) Adds and equals (=) criteria for field comparison. | public void | addColumnIn(String column, Collection values) | public void | addColumnIsNull(String column) | public void | addColumnNotNull(String column) | protected void | addCriteria(Criteria crit) | protected void | addCriteria(Vector criteria) | public void | addEqualTo(String attribute, Object value) | public void | addEqualToColumn(String attribute, String colName) Adds and equals (=) criteria for column comparison. | public void | addEqualToField(String attribute, String fieldName) Adds and equals (=) criteria for field comparison. | public void | addExists(Query subQuery) | public void | addGreaterOrEqualThan(Object attribute, Object value) | public void | addGreaterOrEqualThanField(String attribute, Object value) | public void | addGreaterThan(Object attribute, Object value) | public void | addGreaterThanField(String attribute, Object value) | public void | addGroupBy(String fieldName) Adds a groupby fieldName for ReportQueries. | public void | addGroupBy(FieldHelper aField) | public void | addGroupBy(String[] fieldNames) Adds an array of groupby fieldNames for ReportQueries. | public void | addIn(String attribute, Collection values) | public void | addIn(Object attribute, Query subQuery) | public void | addIsNull(String attribute) | public void | addLessOrEqualThan(Object attribute, Object value) | public void | addLessOrEqualThanField(String attribute, Object value) | public void | addLessThan(Object attribute, Object value) | public void | addLessThanField(String attribute, Object value) | public void | addLike(Object attribute, Object value) | public void | addNotBetween(Object attribute, Object value1, Object value2) | public void | addNotEqualTo(Object attribute, Object value) | public void | addNotEqualToColumn(String attribute, String colName) Adds and equals (<>) criteria for column comparison. | public void | addNotEqualToField(String attribute, String fieldName) Adds and equals (=) criteria for field comparison. | public void | addNotExists(Query subQuery) | public void | addNotIn(String attribute, Collection values) | public void | addNotIn(String attribute, Query subQuery) | public void | addNotLike(String attribute, Object value) | public void | addNotNull(String attribute) | public void | addOrCriteria(Criteria pc) | public void | addOrderBy(String fieldName) | public void | addOrderBy(String fieldName, boolean sortAscending) | public void | addOrderBy(FieldHelper aField) | public void | addOrderByAscending(String fieldName) | public void | addOrderByDescending(String fieldName) | public void | addPathClass(String aPath, Class aClass) Add a hint Class for a path. | public void | addPrefetchedRelationship(String aName) | protected void | addSelectionCriteria(SelectionCriteria selectionCrit) | public void | addSql(String anSqlStatment) | public Criteria | copy(boolean includeGroupBy, boolean includeOrderBy, boolean includePrefetchedRelationships) | public String | getAlias() | public List | getClassesForPath(String aPath) | protected Vector | getCriteria() | public Enumeration | getElements() | List | getGroupby() | List | getOrderby() | public Criteria | getParentCriteria() | public Map | getPathClasses() Gets the pathClasses.
A Map containing hints about what Class to be used for what path segment
If local instance not set, try parent Criteria's instance. | List | getPrefetchedRelationships() Returns the prefetchedRelationships. | public QueryByCriteria | getQuery() | public int | getType() | public UserAlias | getUserAlias() | public boolean | isEmbraced() | public boolean | isEmpty() | public boolean | isNegative() | public void | setAlias(String alias) Sets the alias. | public void | setAlias(String alias, String aliasPath) Sets the alias. | public void | setAlias(UserAlias userAlias) Sets the alias using a userAlias object. | public void | setEmbraced(boolean embraced) | public void | setNegative(boolean negative) Flags the whole Criteria as negative. | void | setParentCriteria(Criteria criteria) | public void | setPathClass(String aPath, Class aClass) Set the Class for a path. | void | setQuery(QueryByCriteria query) | public void | setType(int type) | protected List | splitInCriteria(Object attribute, Collection values, boolean negative, int inLimit) | public String | toString() |
AND | final public static int AND(Code) | | criteria is AND-ed with it's parent
|
IN_LIMIT | final protected static int IN_LIMIT(Code) | | the max. number of parameters in a IN-statement
|
NONE | final public static int NONE(Code) | | criteria has no parent
|
OR | final public static int OR(Code) | | criteria is OR-ed with it's parent
|
PARENT_QUERY_PREFIX | final public static String PARENT_QUERY_PREFIX(Code) | | prefix to identify attributes referencing enclosing query
|
serialVersionUID | final static long serialVersionUID(Code) | | |
Criteria | public Criteria()(Code) | | Constructor declaration
|
Criteria | public Criteria(SelectionCriteria aSelectionCriteria)(Code) | | Constructor with a SelectionCriteria
Parameters: aSelectionCriteria - SelectionCriteria |
_getGroupby | protected List _getGroupby()(Code) | | Gets the groupby for ReportQueries,
the elements are of class Criteria.FieldHelper
List of Criteria.FieldHelper |
_getOrderby | protected List _getOrderby()(Code) | | Answer the Vector with all orderBy,
the elements are of class Criteria.FieldHelper
List |
addAndCriteria | public void addAndCriteria(Criteria pc)(Code) | | ANDs two sets of criteria together:
Parameters: pc - criteria |
addBetween | public void addBetween(Object attribute, Object value1, Object value2)(Code) | | Adds BETWEEN criteria,
customer_id between 1 and 10
Parameters: attribute - The field name to be used Parameters: value1 - The lower boundary Parameters: value2 - The upper boundary |
addColumnEqualTo | public void addColumnEqualTo(String column, Object value)(Code) | | Adds and equals (=) criteria,
CUST_ID = 10034
attribute will NOT be translated into column name
Parameters: column - The column name to be used without translation Parameters: value - An object representing the value of the column |
addColumnEqualToField | public void addColumnEqualToField(String column, Object fieldName)(Code) | | Adds and equals (=) criteria for field comparison.
The field name will be translated into the appropriate columnName by SqlStatement.
The attribute will NOT be translated into column name
Parameters: column - The column name to be used without translation Parameters: fieldName - An object representing the value of the field |
addColumnIn | public void addColumnIn(String column, Collection values)(Code) | | Adds IN criteria,
customer_id in(1,10,33,44)
large values are split into multiple InCriteria
IN (1,10) OR IN(33, 44)
The attribute will NOT be translated into column name
Parameters: column - The column name to be used without translation Parameters: values - The value Collection |
addColumnIsNull | public void addColumnIsNull(String column)(Code) | | Adds is Null criteria,
customer_id is Null
The attribute will NOT be translated into column name
Parameters: column - The column name to be used without translation |
addColumnNotNull | public void addColumnNotNull(String column)(Code) | | Adds not Null criteria,
customer_id is not Null
The attribute will NOT be translated into column name
Parameters: column - The column name to be used without translation |
addCriteria | protected void addCriteria(Vector criteria)(Code) | | |
addEqualTo | public void addEqualTo(String attribute, Object value)(Code) | | Adds and equals (=) criteria,
customer_id = 10034
Parameters: attribute - The field name to be used Parameters: value - An object representing the value of the field |
addEqualToColumn | public void addEqualToColumn(String attribute, String colName)(Code) | | Adds and equals (=) criteria for column comparison.
The column Name will NOT be translated.
name = T_BOSS.LASTNMAE
Parameters: attribute - The field name to be used Parameters: colName - The name of the column to compare with |
addEqualToField | public void addEqualToField(String attribute, String fieldName)(Code) | | Adds and equals (=) criteria for field comparison.
The field name will be translated into the appropriate columnName by SqlStatement.
name = boss.name
Parameters: attribute - The field name to be used Parameters: fieldName - The field name to compare with |
addExists | public void addExists(Query subQuery)(Code) | | Adds an exists(sub query)
Parameters: subQuery - sub-query |
addGreaterOrEqualThan | public void addGreaterOrEqualThan(Object attribute, Object value)(Code) | | Adds GreaterOrEqual Than (>=) criteria,
customer_id >= 10034
Parameters: attribute - The field name to be used Parameters: value - An object representing the value of the field |
addGreaterOrEqualThanField | public void addGreaterOrEqualThanField(String attribute, Object value)(Code) | | Adds GreaterOrEqual Than (>=) criteria,
customer_id >= person_id
Parameters: attribute - The field name to be used Parameters: value - The field name to compare with |
addGreaterThan | public void addGreaterThan(Object attribute, Object value)(Code) | | Adds Greater Than (>) criteria,
customer_id > 10034
Parameters: attribute - The field name to be used Parameters: value - An object representing the value of the field |
addGreaterThanField | public void addGreaterThanField(String attribute, Object value)(Code) | | Adds Greater Than (>) criteria,
customer_id > person_id
Parameters: attribute - The field name to be used Parameters: value - The field to compare with |
addGroupBy | public void addGroupBy(String fieldName)(Code) | | Adds a groupby fieldName for ReportQueries.
Parameters: fieldName - The groupby to set |
addGroupBy | public void addGroupBy(FieldHelper aField)(Code) | | Adds a field for groupby
Parameters: aField - the Field |
addGroupBy | public void addGroupBy(String[] fieldNames)(Code) | | Adds an array of groupby fieldNames for ReportQueries.
Parameters: fieldNames - The groupby to set |
addIn | public void addIn(String attribute, Collection values)(Code) | | Adds IN criteria,
customer_id in(1,10,33,44)
large values are split into multiple InCriteria
IN (1,10) OR IN(33, 44)
Parameters: attribute - The field name to be used Parameters: values - The value Collection |
addIn | public void addIn(Object attribute, Query subQuery)(Code) | | IN Criteria with SubQuery
Parameters: attribute - The field name to be used Parameters: subQuery - The subQuery |
addIsNull | public void addIsNull(String attribute)(Code) | | Adds is Null criteria,
customer_id is Null
Parameters: attribute - The field name to be used |
addLessOrEqualThan | public void addLessOrEqualThan(Object attribute, Object value)(Code) | | Adds LessOrEqual Than (<=) criteria,
customer_id <= 10034
Parameters: attribute - The field name to be used Parameters: value - An object representing the value of the field |
addLessOrEqualThanField | public void addLessOrEqualThanField(String attribute, Object value)(Code) | | Adds LessOrEqual Than (<=) criteria,
customer_id <= person_id
Parameters: attribute - The field name to be used Parameters: value - The field name to compare with |
addLessThan | public void addLessThan(Object attribute, Object value)(Code) | | Adds Less Than (<) criteria,
customer_id < 10034
Parameters: attribute - The field name to be used Parameters: value - An object representing the value of the field |
addLessThanField | public void addLessThanField(String attribute, Object value)(Code) | | Adds Less Than (<) criteria,
customer_id < person_id
Parameters: attribute - The field name to be used Parameters: value - The field to compare with |
addLike | public void addLike(Object attribute, Object value)(Code) | | Adds Like (LIKE) criteria,
customer_name LIKE "m%ller"
See Also: LikeCriteria Parameters: attribute - The field name to be used Parameters: value - An object representing the value of the field |
addNotBetween | public void addNotBetween(Object attribute, Object value1, Object value2)(Code) | | Adds NOT BETWEEN criteria,
customer_id not between 1 and 10
Parameters: attribute - The field name to be used Parameters: value1 - The lower boundary Parameters: value2 - The upper boundary |
addNotEqualTo | public void addNotEqualTo(Object attribute, Object value)(Code) | | Adds NotEqualTo (<>) criteria,
customer_id <> 10034
Parameters: attribute - The field name to be used Parameters: value - An object representing the value of the field |
addNotEqualToColumn | public void addNotEqualToColumn(String attribute, String colName)(Code) | | Adds and equals (<>) criteria for column comparison.
The column Name will NOT be translated.
name <> T_BOSS.LASTNMAE
Parameters: attribute - The field name to be used Parameters: colName - The name of the column to compare with |
addNotEqualToField | public void addNotEqualToField(String attribute, String fieldName)(Code) | | Adds and equals (=) criteria for field comparison.
The field name will be translated into the appropriate columnName by SqlStatement.
name <> boss.name
Parameters: attribute - The field name to be used Parameters: fieldName - The field name to compare with |
addNotExists | public void addNotExists(Query subQuery)(Code) | | Adds a not exists(sub query)
Parameters: subQuery - sub-query |
addNotIn | public void addNotIn(String attribute, Collection values)(Code) | | Adds NOT IN criteria,
customer_id not in(1,10,33,44)
large values are split into multiple InCriteria
NOT IN (1,10) AND NOT IN(33, 44)
Parameters: attribute - The field name to be used Parameters: values - The value Collection |
addNotIn | public void addNotIn(String attribute, Query subQuery)(Code) | | NOT IN Criteria with SubQuery
Parameters: attribute - The field name to be used Parameters: subQuery - The subQuery |
addNotLike | public void addNotLike(String attribute, Object value)(Code) | | Adds Like (NOT LIKE) criteria,
customer_id NOT LIKE 10034
See Also: LikeCriteria Parameters: attribute - The field name to be used Parameters: value - An object representing the value of the field |
addNotNull | public void addNotNull(String attribute)(Code) | | Adds not Null criteria,
customer_id is not Null
Parameters: attribute - The field name to be used |
addOrCriteria | public void addOrCriteria(Criteria pc)(Code) | | ORs two sets of criteria together:
active = true AND balance < 0 OR active = true AND overdraft = 0
Parameters: pc - criteria |
addOrderBy | public void addOrderBy(String fieldName)(Code) | | Adds a field for orderBy, order is ASCENDING
Parameters: fieldName - The field name to be used |
addOrderBy | public void addOrderBy(String fieldName, boolean sortAscending)(Code) | | Adds a field for orderBy
Parameters: fieldName - the field name to be used Parameters: sortAscending - true for ASCENDING, false for DESCENDING |
addOrderBy | public void addOrderBy(FieldHelper aField)(Code) | | Adds a field for orderBy
Parameters: aField - the Field |
addOrderByAscending | public void addOrderByAscending(String fieldName)(Code) | | Adds a field for orderBy ASCENDING
Parameters: fieldName - The field name to be used |
addOrderByDescending | public void addOrderByDescending(String fieldName)(Code) | | Adds a field for orderBy DESCENDING
Parameters: fieldName - The field name to be used |
addPathClass | public void addPathClass(String aPath, Class aClass)(Code) | | Add a hint Class for a path. Used for relationships to extents.
SqlStatment will use these hint classes when resolving the path.
Without these hints SqlStatment will use the base class the
relationship points to ie: Article instead of CdArticle.
Parameters: aPath - the path segment ie: allArticlesInGroup Parameters: aClass - the Class ie: CdArticle See Also: org.apache.ojb.broker.QueryTest.testInversePathExpression |
addPrefetchedRelationship | public void addPrefetchedRelationship(String aName)(Code) | | add the name of a Relationship for prefetch read
Parameters: aName - the name of the relationship |
addSql | public void addSql(String anSqlStatment)(Code) | | Adds freeform SQL criteria,
REVERSE(name) like 're%'
Parameters: anSqlStatment - The free form SQL-Statement |
copy | public Criteria copy(boolean includeGroupBy, boolean includeOrderBy, boolean includePrefetchedRelationships)(Code) | | make a copy of the criteria
Parameters: includeGroupBy - if true Parameters: includeOrderBy - if ture Parameters: includePrefetchedRelationships - if true a copy of the criteria |
getCriteria | protected Vector getCriteria()(Code) | | Get a Vector with all sub criteria
Vector |
getElements | public Enumeration getElements()(Code) | | Get an Enumeration with all sub criteria
Enumeration |
getGroupby | List getGroupby()(Code) | | Gets the groupby for ReportQueries of all Criteria and Sub Criteria
the elements are of class FieldHelper
List of FieldHelper |
getOrderby | List getOrderby()(Code) | | Answer the orderBy of all Criteria and Sub Criteria
the elements are of class Criteria.FieldHelper
List |
getParentCriteria | public Criteria getParentCriteria()(Code) | | the parent criteria |
getPathClasses | public Map getPathClasses()(Code) | | Gets the pathClasses.
A Map containing hints about what Class to be used for what path segment
If local instance not set, try parent Criteria's instance. If this is
the top-level Criteria, try the m_query's instance
Returns a Map |
getPrefetchedRelationships | List getPrefetchedRelationships()(Code) | | Returns the prefetchedRelationships.
List |
getType | public int getType()(Code) | | Answer the type
int |
isEmbraced | public boolean isEmbraced()(Code) | | ANDed criteria are embraced
true if embraced, |
isEmpty | public boolean isEmpty()(Code) | | Answer true if no sub criteria available
boolean |
isNegative | public boolean isNegative()(Code) | | Returns the negative. |
setAlias | public void setAlias(String alias)(Code) | | Sets the alias. Empty String is regarded as null.
Parameters: alias - The alias to set |
setAlias | public void setAlias(String alias, String aliasPath)(Code) | | Sets the alias. Empty String is regarded as null.
Parameters: alias - The alias to set Parameters: aliasPath - The path segment(s) to which the alias applies |
setAlias | public void setAlias(UserAlias userAlias)(Code) | | Sets the alias using a userAlias object.
Parameters: userAlias - The alias to set |
setEmbraced | public void setEmbraced(boolean embraced)(Code) | | Set embraced
Parameters: embraced - true if criteria is to be surrounded by braces |
setNegative | public void setNegative(boolean negative)(Code) | | Flags the whole Criteria as negative.
Parameters: negative - The negative to set. |
setParentCriteria | void setParentCriteria(Criteria criteria)(Code) | | Parameters: criteria - |
setPathClass | public void setPathClass(String aPath, Class aClass)(Code) | | Set the Class for a path. Used for relationships to extents.
SqlStatment will use this class when resolving the path.
Without this hint SqlStatment will use the base class the
relationship points to ie: Article instead of CdArticle.
Using this method is the same as adding just one hint
Parameters: aPath - the path segment ie: allArticlesInGroup Parameters: aClass - the Class ie: CdArticle See Also: org.apache.ojb.broker.QueryTest.testInversePathExpression See Also: Criteria.addPathClass |
setType | public void setType(int type)(Code) | | Set the type
Parameters: type - OR, AND, NONE |
splitInCriteria | protected List splitInCriteria(Object attribute, Collection values, boolean negative, int inLimit)(Code) | | Answer a List of InCriteria based on values, each InCriteria
contains only inLimit values
Parameters: attribute - Parameters: values - Parameters: negative - Parameters: inLimit - the maximum number of values for IN (-1 for no limit) List of InCriteria |
|
|