Class JRSqlAbstractInClause
java.lang.Object
net.sf.jasperreports.engine.query.JRSqlAbstractInClause
- All Implemented Interfaces:
JRClauseFunction
- Direct Known Subclasses:
JRSqlInClause,JRSqlNotInClause
Base (NOT) IN clause function for SQL queries.
The first token in the $X{...} syntax is the function ID token. Possible values for the (NOT) IN clause function ID token are:
INNOTIN
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final Stringstatic final Stringprotected static final intprotected static final intprotected static final intFields inherited from interface net.sf.jasperreports.engine.query.JRClauseFunction
CLAUSE_FALSISM, CLAUSE_TRUISM -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract voidappendAndOrOperator(StringBuffer sBuffer) protected abstract voidappendInOperator(StringBuffer sBuffer) protected abstract voidappendNullOperator(StringBuffer sBuffer) voidapply(JRClauseTokens clauseTokens, JRQueryClauseContext queryContext) Creates a (NOT) IN SQL clause.protected Collection<?> protected abstract Stringprotected voidhandleNoValues(JRClauseTokens clauseTokens, JRQueryClauseContext queryContext) Generate a SQL clause that will always evaluate to true (e.g.
-
Field Details
-
EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_DB_COLUMN_TOKEN_MISSING
- See Also:
-
EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_INVALID_PARAMETER_TYPE
- See Also:
-
EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_PARAMETER_TOKEN_MISSING
- See Also:
-
POSITION_DB_COLUMN
protected static final int POSITION_DB_COLUMN- See Also:
-
POSITION_PARAMETER
protected static final int POSITION_PARAMETER- See Also:
-
POSITION_NO_VALUES_RESULT
protected static final int POSITION_NO_VALUES_RESULT- See Also:
-
-
Constructor Details
-
JRSqlAbstractInClause
protected JRSqlAbstractInClause()
-
-
Method Details
-
apply
Creates a (NOT) IN SQL clause.The function expects two clause tokens (after the ID token), the third one being optional:
- The first token is the SQL column to be used in the clause.
- The second token is the name of the report parameter that contains the value list.
The value of this parameter has to be an array, ajava.util.Collectionornull. - The third token is an optional boolean representing the logical value (true/false) that the clause should return in case the list of values is null or empty.
The function constructs one of the following clauses:
- When the function ID token is IN:
- If the parameter's value is a collection of not null values, the function constructs
a
<column_name> IN (?, ?, .., ?)clause - If the parameter's value is a collection containing both null and not null values, the
function constructs a
(<column_name> IS NULL OR <column_name> IN (?, ?, .., ?))clause - If the parameter's value is a collection containing only null values, the function
constructs a
<column_name> IS NULLclause
- If the parameter's value is a collection of not null values, the function constructs
a
- When the function ID token is NOTIN:
- If the parameter's value is a collection of not null values, the function constructs
a
<column_name> NOT IN (?, ?, .., ?)clause - If the parameter's value is a collection containing both null and not null values, the
function constructs a
(<column_name> IS NOT NULL AND <column_name> NOT IN (?, ?, .., ?))clause - If the parameter's value is a collection containing only null values, the function
constructs a
<column_name> IS NOT NULLclause
- If the parameter's value is a collection of not null values, the function constructs
a
- If the values list is null or empty, both IN and NOTIN functions generate a SQL clause that
will evaluate to true (e.g.
0 = 0) or false (e.g.1 = 0) according to the value of the optional third parameter of the clause. This third optional parameter has itself a default value that is controlled by the net.sf.jasperreports.sql.clause.in.novalues.result and the net.sf.jasperreports.sql.clause.notin.novalues.result configuration properties, respectively.
- Specified by:
applyin interfaceJRClauseFunction- Parameters:
clauseTokens-queryContext-
-
handleNoValues
Generate a SQL clause that will always evaluate to true (e.g. '0 = 0').- Parameters:
queryContext- the query context
-
getNoValuesResultProperty
-
convert
- Parameters:
paramName- the parameter nameparamValue- the parameter value- Returns:
- a
java.util.Collectiontype object obtained either by converting an array to a list or by a cast tojava.util.Collectiontype.
-
appendInOperator
-
appendNullOperator
-
appendAndOrOperator
-