Class SQLLessOrGreaterBaseClause

java.lang.Object
net.sf.jasperreports.engine.query.SQLLessOrGreaterBaseClause
All Implemented Interfaces:
JRClauseFunction
Direct Known Subclasses:
DateRangeSQLLessOrGreaterClause, JRSqlLessOrGreaterClause

public abstract class SQLLessOrGreaterBaseClause extends Object implements JRClauseFunction
Author:
Sanda Zaharia (shertage@users.sourceforge.net)
  • Field Details

    • EXCEPTION_MESSAGE_KEY_QUERY_LESS_GREATER_CLAUSE_DB_COLUMN_TOKEN_MISSING

      public static final String EXCEPTION_MESSAGE_KEY_QUERY_LESS_GREATER_CLAUSE_DB_COLUMN_TOKEN_MISSING
      See Also:
    • EXCEPTION_MESSAGE_KEY_QUERY_LESS_GREATER_CLAUSE_NAME_TOKEN_MISSING

      public static final String EXCEPTION_MESSAGE_KEY_QUERY_LESS_GREATER_CLAUSE_NAME_TOKEN_MISSING
      See Also:
    • EXCEPTION_MESSAGE_KEY_QUERY_LESS_GREATER_CLAUSE_PARAMETER_TOKEN_MISSING

      public static final String EXCEPTION_MESSAGE_KEY_QUERY_LESS_GREATER_CLAUSE_PARAMETER_TOKEN_MISSING
      See Also:
    • POSITION_CLAUSE_ID

      protected static final int POSITION_CLAUSE_ID
      See Also:
    • POSITION_DB_COLUMN

      protected static final int POSITION_DB_COLUMN
      See Also:
    • POSITION_PARAMETER

      protected static final int POSITION_PARAMETER
      See Also:
    • OPERATOR_LESS

      protected static final String OPERATOR_LESS
      See Also:
    • OPERATOR_LESS_OR_EQUAL

      protected static final String OPERATOR_LESS_OR_EQUAL
      See Also:
    • OPERATOR_GREATER

      protected static final String OPERATOR_GREATER
      See Also:
    • OPERATOR_GREATER_OR_EQUAL

      protected static final String OPERATOR_GREATER_OR_EQUAL
      See Also:
  • Constructor Details

    • SQLLessOrGreaterBaseClause

      protected SQLLessOrGreaterBaseClause()
  • Method Details

    • apply

      public void apply(JRClauseTokens clauseTokens, JRQueryClauseContext queryContext)
      Creates either a LESS or a GREATER SQL clause, depending on the clause ID.

      The method expects two clause tokens (after the ID token):

      • The first token is the SQL column (or column combination) to be used in the clause.
      • The second token is the name of the report parameter that contains the value to compare to.

      The method constructs one of the following clauses:

      • column < ? if the clause ID is LESS
      • column <= ? if the clause ID is LESS]
      • column >= ? if the clause ID is GREATER
      • column > ? if the clause ID is [GREATER
      If the value to compare to is null, the method generates a SQL clause that will always evaluate to true (e.g. 0 = 0).

      Specified by:
      apply in interface JRClauseFunction
      Parameters:
      clauseTokens - the clause tokens
      queryContext - the query context
    • createParameterHandler

      protected abstract ClauseFunctionParameterHandler createParameterHandler(JRQueryClauseContext queryContext, String clauseId, String parameterName)
    • handleLessOrGreaterOperator

      protected void handleLessOrGreaterOperator(StringBuffer sBuffer, String clauseId)
      Appends the appropriate inequality sign to the query string, depending on the clause ID value
      Parameters:
      sBuffer - the StringBuffer that contains the generated query
      clauseId - the clause ID