Ontimize 5.2072EN

com.ontimize.db
Class SQLStatementBuilder.ExtendedSQLConditionValuesProcessor

java.lang.Object
  extended bycom.ontimize.db.SQLStatementBuilder.DefaultSQLConditionValuesProcessor
      extended bycom.ontimize.db.SQLStatementBuilder.ExtendedSQLConditionValuesProcessor
All Implemented Interfaces:
SQLStatementBuilder.SQLConditionValuesProcessor
Direct Known Subclasses:
ContainsExtendedSQLConditionValuesProcessor
Enclosing class:
SQLStatementBuilder

public static class SQLStatementBuilder.ExtendedSQLConditionValuesProcessor
extends SQLStatementBuilder.DefaultSQLConditionValuesProcessor

This class provides a implementation of the SQLConditionValuesProcessor interface.

This class extends DefaultSQLConditionValuesProcessor and permits process complex conditions where condition key doesn't have to be the column of a table in a database. EXPRESSION_KEY is used as condition key to indicate which is a complex condition

Using classes that implements Expression, Field, Operator interfaces is necessary to define a complex condition. Each class that implements the Expression interface has three important parts. The left operand that can only be another expression or a class that implements Field interface The right operand that can be another expression or a value The operator that has to be a class that implement Operator interface

In the next examples the basic implementations have been used:

  Example for a simple expression:
  
  	Operator equalOperator=BasicOperator.EQUAL_OP;
  	Field field = new BasicField("columnName1");
  
  	Expression expression = new BasicExpression(field,equalOperator,"filterValue");
  	Hashtable conditions=new Hashtable();
  	conditions.put(ExtendedSQLConditionValuesProcessor.EXPRESSION_KEY,expression);
  
  Example for a complex expression:
  	Operator equalOperator=BasicOperator.EQUAL_OP;
  	Field field1 = new BasicField("columnName1");
  	Expression expression1 = new BasicExpression(field1,equalOperator,"filterValue");
  	
  	Field field2 = new BasicField("columnName2");
  	Expression expression2 = new BasicExpression(field2,BasicOperator.LESS,new Integer(10));
  
  	Expression totalExpression = new Expression(expression1,BasicOperator.AND,expression2);
  
  	Hashtable conditions=new Hashtable();
   	conditions.put(ExtendedSQLConditionValuesProcessor.EXPRESSION_KEY,totalExpression);
  

Author:
Imatia Innovation S.L.
See Also:
SQLStatementBuilder.Expression

Field Summary
static java.lang.String EXPRESSION_KEY
          Identifier used as condition key when has a complex expression.
 
Fields inherited from class com.ontimize.db.SQLStatementBuilder.DefaultSQLConditionValuesProcessor
handler, upperFunction, upperLike, upperStrings
 
Constructor Summary
SQLStatementBuilder.ExtendedSQLConditionValuesProcessor()
           
SQLStatementBuilder.ExtendedSQLConditionValuesProcessor(boolean upperLike)
          Creates a ExtendedSQLConditionValuesProcessor where every condition that uses LIKE is case-insensitive.
SQLStatementBuilder.ExtendedSQLConditionValuesProcessor(boolean upperStrings, boolean upperLike)
          Creates a ExtendedSQLConditionValuesProcessor where every condition that uses LIKE or is a column of String type is case-insensitive.
 
Method Summary
 java.lang.String createQueryConditions(java.util.Hashtable conditions, java.util.Vector wildcards, java.util.Vector values)
          Creates the condition string for a SQL Statement.
static java.lang.String createQueryConditionsExpress(SQLStatementBuilder.Expression expression)
          Creates the condition string from a expression.
static void createQueryConditionsExpress(SQLStatementBuilder.Expression expression, java.lang.StringBuffer sb)
          Creates the condition string from a expression.
protected  java.lang.String createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression, java.util.Vector values)
          Creates the condition string from a expression and stores required values in a vector.
protected  void createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression, java.util.Vector values, java.lang.StringBuffer sb)
          Creates the condition string from a expression.
protected  java.lang.String getColumnName(java.lang.String name)
          Returns the column name in square bracket if the name contains a special characters
protected  java.lang.String renderQueryConditionsFromExpression(SQLStatementBuilder.Expression expression)
           
protected  void renderQueryConditionsFromExpression(SQLStatementBuilder.Expression expression, java.lang.StringBuffer sb)
           
 
Methods inherited from class com.ontimize.db.SQLStatementBuilder.DefaultSQLConditionValuesProcessor
getSQLStatementHandler, hasParenthesis, setSQLStatementHandler
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EXPRESSION_KEY

public static final java.lang.String EXPRESSION_KEY
Identifier used as condition key when has a complex expression.

See Also:
Constant Field Values
Constructor Detail

SQLStatementBuilder.ExtendedSQLConditionValuesProcessor

public SQLStatementBuilder.ExtendedSQLConditionValuesProcessor()

SQLStatementBuilder.ExtendedSQLConditionValuesProcessor

public SQLStatementBuilder.ExtendedSQLConditionValuesProcessor(boolean upperLike)
Creates a ExtendedSQLConditionValuesProcessor where every condition that uses LIKE is case-insensitive.

Inserts a upper function in both sides of LIKE conditions (UPPER(Field) LIKE UPPER(Value))

Parameters:
upperLike - true if the LIKE condition should be case-insensitive

SQLStatementBuilder.ExtendedSQLConditionValuesProcessor

public SQLStatementBuilder.ExtendedSQLConditionValuesProcessor(boolean upperStrings,
                                                               boolean upperLike)
Creates a ExtendedSQLConditionValuesProcessor where every condition that uses LIKE or is a column of String type is case-insensitive.

Inserts a upper function in both sides of LIKE conditions (UPPER(Field) LIKE UPPER(Value)) Inserts a upper function in both sides if column type is a String (UPPER(Field) LIKE UPPER(String))

Parameters:
upperStrings - true if the String column type should be case-insensitive
upperLike - true if the LIKE condition should be case-insensitive
Method Detail

getColumnName

protected java.lang.String getColumnName(java.lang.String name)
Returns the column name in square bracket if the name contains a special characters

Parameters:
name - column name to checks
Returns:
the column name in square bracket if it's necessary

createQueryConditionsExpress

public static java.lang.String createQueryConditionsExpress(SQLStatementBuilder.Expression expression)
Creates the condition string from a expression. This condition string be used after WHERE clause in the SQL Statement.

Parameters:
expression - a class that implements Expression interface
Returns:
a String where is stored a condition in text format

createQueryConditionsExpress

public static void createQueryConditionsExpress(SQLStatementBuilder.Expression expression,
                                                java.lang.StringBuffer sb)
Creates the condition string from a expression.

Parameters:
expression - a class that implements Expression interface
sb - StringBuffer where the condition string is stored.

renderQueryConditionsFromExpression

protected java.lang.String renderQueryConditionsFromExpression(SQLStatementBuilder.Expression expression)

renderQueryConditionsFromExpression

protected void renderQueryConditionsFromExpression(SQLStatementBuilder.Expression expression,
                                                   java.lang.StringBuffer sb)

createQueryConditionsFromExpression

protected java.lang.String createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression,
                                                               java.util.Vector values)
Creates the condition string from a expression and stores required values in a vector.

Parameters:
expression - a class that implements Expression interface
values - a list where the required values for the condition are stored
Returns:
a String where is stored a condition in text format

createQueryConditionsFromExpression

protected void createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression,
                                                   java.util.Vector values,
                                                   java.lang.StringBuffer sb)
Creates the condition string from a expression. The condition string is stored in the StringBuffer param and the required values in a Vector param

Parameters:
expression - a class that implements Expression interface
values - a list where the required values for the condition are stored
sb - a StringBuffer where the condition string is stored

createQueryConditions

public java.lang.String createQueryConditions(java.util.Hashtable conditions,
                                              java.util.Vector wildcards,
                                              java.util.Vector values)
Creates the condition string for a SQL Statement.

Specified by:
createQueryConditions in interface SQLStatementBuilder.SQLConditionValuesProcessor
Overrides:
createQueryConditions in class SQLStatementBuilder.DefaultSQLConditionValuesProcessor
Parameters:
conditions - a condition list
wildcards - column list that can use wildcards
values - vector where the value of each processed conditions is stored
Returns:

Ontimize