Class JRSqlAbstractInClause
- java.lang.Object
-
- net.sf.jasperreports.engine.query.JRSqlAbstractInClause
-
- All Implemented Interfaces:
JRClauseFunction
- Direct Known Subclasses:
JRSqlInClause
,JRSqlNotInClause
public abstract class JRSqlAbstractInClause extends Object implements JRClauseFunction
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:
IN
NOTIN
- Author:
- Lucian Chirita (lucianc@users.sourceforge.net)
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
CLAUSE_TRUISM
static String
EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_DB_COLUMN_TOKEN_MISSING
static String
EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_INVALID_PARAMETER_TYPE
static String
EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_PARAMETER_TOKEN_MISSING
protected static int
POSITION_DB_COLUMN
protected static int
POSITION_PARAMETER
-
Constructor Summary
Constructors Modifier Constructor Description protected
JRSqlAbstractInClause()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract void
appendAndOrOperator(StringBuffer sBuffer)
protected abstract void
appendInOperator(StringBuffer sBuffer)
protected abstract void
appendNullOperator(StringBuffer sBuffer)
void
apply(JRClauseTokens clauseTokens, JRQueryClauseContext queryContext)
Creates a (NOT) IN SQL clause.protected Collection<?>
convert(String paramName, Object paramValue)
protected void
handleNoValues(JRQueryClauseContext queryContext)
Generate a SQL clause that will always evaluate to true (e.g
-
-
-
Field Detail
-
EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_DB_COLUMN_TOKEN_MISSING
public static final String EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_DB_COLUMN_TOKEN_MISSING
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_INVALID_PARAMETER_TYPE
public static final String EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_INVALID_PARAMETER_TYPE
- See Also:
- Constant Field Values
-
EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_PARAMETER_TOKEN_MISSING
public static final String EXCEPTION_MESSAGE_KEY_QUERY_IN_CLAUSE_PARAMETER_TOKEN_MISSING
- See Also:
- Constant Field Values
-
POSITION_DB_COLUMN
protected static final int POSITION_DB_COLUMN
- See Also:
- Constant Field Values
-
POSITION_PARAMETER
protected static final int POSITION_PARAMETER
- See Also:
- Constant Field Values
-
CLAUSE_TRUISM
protected static final String CLAUSE_TRUISM
- See Also:
- Constant Field Values
-
-
Method Detail
-
apply
public void apply(JRClauseTokens clauseTokens, JRQueryClauseContext queryContext)
Creates a (NOT) IN SQL clause.The function expects two clause tokens (after the ID token):
- 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.Collection
ornull
.
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 NULL
clause
- 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 NULL
clause
- 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 always evaluate to true (e.g.
0 = 0
).
- Specified by:
apply
in interfaceJRClauseFunction
- Parameters:
clauseTokens
-queryContext
-
-
handleNoValues
protected void handleNoValues(JRQueryClauseContext queryContext)
Generate a SQL clause that will always evaluate to true (e.g. '0 = 0
').- Parameters:
queryContext
- the query context
-
convert
protected Collection<?> convert(String paramName, Object paramValue)
- Parameters:
paramName
- the parameter nameparamValue
- the parameter value- Returns:
- a
java.util.Collection
type object obtained either by converting an array to a list or by a cast tojava.util.Collection
type.
-
appendInOperator
protected abstract void appendInOperator(StringBuffer sBuffer)
-
appendNullOperator
protected abstract void appendNullOperator(StringBuffer sBuffer)
-
appendAndOrOperator
protected abstract void appendAndOrOperator(StringBuffer sBuffer)
-
-