public static class SQLStatementBuilder.ExtendedSQLConditionValuesProcessor extends SQLStatementBuilder.DefaultSQLConditionValuesProcessor
SQLConditionValuesProcessor interface.
This class extends
Using classes that implements
In the next examples the basic implementations have been used:
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
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
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);
SQLStatementBuilder.Expression| Modifier and Type | Field and Description |
|---|---|
static String |
EXPRESSION_KEY
Identifier used as condition key when has a complex expression.
|
static String |
FILTER_KEY |
handler, upperFunction, upperLike, upperStrings| Constructor and Description |
|---|
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. |
| Modifier and Type | Method and Description |
|---|---|
String |
createQueryConditions(Hashtable conditions,
Vector wildcards,
Vector values)
Creates the condition string for a SQL Statement.
|
static String |
createQueryConditionsExpress(SQLStatementBuilder.Expression expression)
Creates the condition string from a expression.
|
static void |
createQueryConditionsExpress(SQLStatementBuilder.Expression expression,
StringBuffer sb)
Creates the condition string from a expression.
|
protected String |
createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression,
Vector values)
Creates the condition string from a expression and stores required
values in a vector.
|
protected String |
createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression,
Vector values,
boolean upper)
Creates the condition string from a expression and stores required
values in a vector.
|
protected void |
createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression,
Vector values,
StringBuffer sb)
Creates the condition string from a expression.
|
protected void |
createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression,
Vector values,
StringBuffer sb,
boolean upper)
Creates the condition string from a expression.
|
protected String |
getColumnName(String name)
Returns the column name in square bracket if the name contains a
special characters
|
protected String |
renderQueryConditionsFromExpression(SQLStatementBuilder.Expression expression) |
protected void |
renderQueryConditionsFromExpression(SQLStatementBuilder.Expression expression,
StringBuffer sb) |
getSQLStatementHandler, getUpperLike, getUpperStrings, hasParenthesis, setSQLStatementHandlerpublic static final String EXPRESSION_KEY
public static final String FILTER_KEY
public SQLStatementBuilder.ExtendedSQLConditionValuesProcessor()
public SQLStatementBuilder.ExtendedSQLConditionValuesProcessor(boolean upperLike)
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))
upperLike - true if the LIKE condition should be case-insensitivepublic SQLStatementBuilder.ExtendedSQLConditionValuesProcessor(boolean upperStrings,
boolean upperLike)
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))
upperStrings - true if the String column type should be case-insensitiveupperLike - true if the LIKE condition should be case-insensitiveprotected String getColumnName(String name)
name - column name to checkspublic static String createQueryConditionsExpress(SQLStatementBuilder.Expression expression)
expression - a class that implements Expression interfacepublic static void createQueryConditionsExpress(SQLStatementBuilder.Expression expression, StringBuffer sb)
expression - a class that implements Expression interfacesb - StringBuffer where the condition string is
stored.protected String renderQueryConditionsFromExpression(SQLStatementBuilder.Expression expression)
protected void renderQueryConditionsFromExpression(SQLStatementBuilder.Expression expression, StringBuffer sb)
protected String createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression, Vector values)
expression - a class that implements Expression interfacevalues - a list where the required values for the condition are
storedString where is stored a condition in text
formatprotected String createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression, Vector values, boolean upper)
expression - a class that implements Expression interfacevalues - a list where the required values for the condition are
storedString where is stored a condition in text
formatprotected void createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression, Vector values, StringBuffer sb)
StringBuffer param and the required
values in a Vector paramexpression - a class that implements Expression interfacevalues - a list where the required values for the condition are
storedsb - a StringBuffer where the condition string is
storedprotected void createQueryConditionsFromExpression(SQLStatementBuilder.Expression expression, Vector values, StringBuffer sb, boolean upper)
StringBuffer param and the required
values in a Vector paramexpression - a class that implements Expression interfacevalues - a list where the required values for the condition are
storedsb - a StringBuffer where the condition string is
storedupper - Boolean that enable the String compare in upper case,
i.e., for non case-sensitive.public String createQueryConditions(Hashtable conditions, Vector wildcards, Vector values)
createQueryConditions in interface SQLStatementBuilder.SQLConditionValuesProcessorcreateQueryConditions in class SQLStatementBuilder.DefaultSQLConditionValuesProcessorconditions - a condition listwildcards - column list that can use wildcardsvalues - vector where the value of each processed conditions is
storedCopyright © 2016 Imatia Innovation S.L.. All rights reserved.