Modifier and Type | Method and Description |
---|---|
static StringBuffer |
addToWhereClause(StringBuffer whereClause,
String operator,
String expression)
Adds the supplied operator and expression to an existing (and supplied) whereClause.
|
static boolean |
containsWildcard(String expression)
Determines whether the supplied expression contains a SQL wildcard character.
|
static String |
createCommaSeparatedValues(Object... values)
Creates a list of comma separated (database column) values.
|
static <T extends Enum<T> & LocalizableEnumeration> |
createDecodeArgument(String expression,
Class<T> localizableEnumeration,
Locale locale)
Creates a String which can be used as an argument to Oracle's decode function.
|
static String |
createDecodeArgument(String expression,
Collection<? extends CodeDescription> codeDescriptions,
String defaultValue)
Creates a String which can be used as an argument to Oracle's decode
function.
|
static String |
createEndsWithParameter(String expression)
Creates a SQL parameter that can be used in a SQL LIKE clause suitable for selecting columns that end with
the supplied expression.
|
static String |
createInClause(String databaseColumn,
Object... values)
Creates an IN clause for a SQL statement.
|
static String |
createNotInClause(String databaseColumn,
Object... values)
Creates a NOT IN clause for a SQL statement.
|
static String |
createStartsWithParameter(String expression)
Creates a SQL parameter that can be used in a SQL LIKE clause suitable for selecting columns that start with
the supplied expression.
|
static String |
createStoredProcedureCall(String name,
StoredProcedureParameter... parameters)
Creates a SQL statement to call a stored procedure.
|
static StringBuffer |
createWhereClause(String expression)
Creates a sql WHERE clause.
|
static String |
quoteSqlValue(Object value)
Quotes a SQL value.
|
public static StringBuffer createWhereClause(String expression)
addToWhereClause(StringBuffer, String, String)
to construct more
complex WHERE clauses. The following code for example creates a clause that looks like:
WHERE (A=1 AND B=1) OR B=2 AND C IN('a','b','c')
StringBuffer whereClause = createWhereClause("(A=1 AND B=1)"); addToWhereClause(whereClause, "OR", "B=2"); addToWhereClause(whereClause, "AND", createInClause("C", new String [] {"a", "b", "c"}));
expression
- The initial expression to add to the newly created WHERE clause.IllegalArgumentException
- When the supplied expression is empty.NullPointerException
- When the supplied expression is null.public static StringBuffer addToWhereClause(StringBuffer whereClause, String operator, String expression)
whereClause
- WHERE clause created by createWhereClause(String)
.operator
- An operator like 'AND', 'OR', '=' et cetera.expression
- A SQL expression.public static boolean containsWildcard(String expression)
expression
- Expression to check for SQL wildcard characters.NullPointerException
- When the supplied expression is null.public static String createStartsWithParameter(String expression)
expression
- The SQL expression.NullPointerException
- When the supplied expression is null.public static String createEndsWithParameter(String expression)
expression
- The SQL expression.NullPointerException
- When the supplied expression is null.public static String createInClause(String databaseColumn, Object... values)
databaseColumn
- The database column as it should appear in the SQL statement.
values
- The values to appear in the IN clause.
IllegalArgumentException
- When either the supplied databaseColumn or the supplied values array is empty.NullPointerException
- When either the supplied databaseColumn or the supplied values array is null.public static String createNotInClause(String databaseColumn, Object... values)
databaseColumn
- The database column as it should appear in the SQL statement.
values
- The values to appear in the NOT IN clause.
IllegalArgumentException
- When either the supplied databaseColumn or the supplied values array is empty.NullPointerException
- When either the supplied databaseColumn or the supplied values array is null.public static String createCommaSeparatedValues(Object... values)
values
- The values that must be comma separated.public static <T extends Enum<T> & LocalizableEnumeration> String createDecodeArgument(String expression, Class<T> localizableEnumeration, Locale locale)
decode(expression, code, value [,code, value]... [,defaultValue])
createDecodeArgument(String, Collection, String)
.T
- The type of the localizable enumeration.expression
- The decode expression.localizableEnumeration
- The localizable enumeration to be used in the decode function.locale
- The locale to localize the descriptions of the supplied constants.
NullPointerException
- When either the supplied expression or localizableEnumeration is null.IllegalArgumentException
- When the supplied expression is empty.public static String createDecodeArgument(String expression, Collection<? extends CodeDescription> codeDescriptions, String defaultValue)
decode(expression, code, value [,code, value]... [,defaultValue])
expression
- The decode expression.codeDescriptions
- The code/description pairs to be used in the
decode function.defaultValue
- The optional default value.NullPointerException
- When either the supplied expression or
codeDescriptions is null.IllegalArgumentException
- When the supplied expression or
codeDescriptions is empty.public static String quoteSqlValue(Object value)
value
- The value to quote.NullPointerException
- When the supplied value is null.public static String createStoredProcedureCall(String name, StoredProcedureParameter... parameters)
name
- Name of the stored procedure.parameters
- The (optional) parameters.NullPointerException
- When the supplied name is null.Copyright © 2008–2018. All rights reserved.