net.sf.jasperreports.engine.query
Class JRSqlAbstractInClause

java.lang.Object
  extended by net.sf.jasperreports.engine.query.JRSqlAbstractInClause
All Implemented Interfaces:
JRClauseFunction
Direct Known Subclasses:
JRSqlInClause, JRSqlNotInClause

public abstract class JRSqlAbstractInClause
extends java.lang.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:

Version:
$Id: JRSqlAbstractInClause.java 4643 2011-09-29 09:37:57Z lucianc $
Author:
Lucian Chirita (lucianc@users.sourceforge.net)

Field Summary
protected static java.lang.String CLAUSE_TRUISM
           
protected static int POSITION_DB_COLUMN
           
protected static int POSITION_PARAMETER
           
 
Constructor Summary
protected JRSqlAbstractInClause()
           
 
Method Summary
protected abstract  void appendAndOrOperator(java.lang.StringBuffer sBuffer)
           
protected abstract  void appendInOperator(java.lang.StringBuffer sBuffer)
           
protected abstract  void appendNullOperator(java.lang.StringBuffer sBuffer)
           
 void apply(JRClauseTokens clauseTokens, JRQueryClauseContext queryContext)
          Creates a (NOT) IN SQL clause.
protected  java.util.Collection<?> convert(java.lang.String paramName, java.lang.Object paramValue)
           
protected  void handleNoValues(JRQueryClauseContext queryContext)
          Generate a SQL clause that will always evaluate to true (e.g.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

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 java.lang.String CLAUSE_TRUISM
See Also:
Constant Field Values
Constructor Detail

JRSqlAbstractInClause

protected JRSqlAbstractInClause()
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 function constructs one of the following clauses:

  1. 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
  2. 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
  3. 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 interface JRClauseFunction
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 java.util.Collection<?> convert(java.lang.String paramName,
                                          java.lang.Object paramValue)
Parameters:
paramName - the parameter name
paramValue - the parameter value
Returns:
a java.util.Collection type object obtained either by converting an array to a list or by a cast to java.util.Collection type.

appendInOperator

protected abstract void appendInOperator(java.lang.StringBuffer sBuffer)

appendNullOperator

protected abstract void appendNullOperator(java.lang.StringBuffer sBuffer)

appendAndOrOperator

protected abstract void appendAndOrOperator(java.lang.StringBuffer sBuffer)


© 2001-2010 Jaspersoft Corporation www.jaspersoft.com