public class BinaryCondition extends Condition
"(<column1> <binaryOp> <column2>)"
.Modifier and Type | Class and Description |
---|---|
static class |
BinaryCondition.Op
Enum representing the binary midfix operations supported in a SQL
condition, e.g.
|
ALL_SYMBOL, NULL_VALUE, QUESTION_MARK
Constructor and Description |
---|
BinaryCondition(BinaryCondition.Op binaryOp,
Object leftValue,
Object rightValue)
|
BinaryCondition(BinaryCondition.Op binaryOp,
SqlObject leftValue,
SqlObject rightValue) |
BinaryCondition(Object binaryOpStr,
Object leftValue,
Object rightValue)
|
Modifier and Type | Method and Description |
---|---|
protected void |
appendCustomIfNotNull(AppendableExt app,
SqlObject obj)
Appends the given custom clause to the given AppendableExt, handling
null and enclosing parens. |
protected void |
appendNestedClauses(AppendableExt app,
SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses)
Appends the given nested clauses to the given AppendableExt, handling
empty nested clauses and enclosing parens.
|
void |
appendTo(AppendableExt app)
Appends this object to the given AppendableExt.
|
protected static boolean |
areEmpty(SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses)
Determines if any of the given clauses are non-empty.
|
protected void |
closeParen(AppendableExt app)
Appends a close parenthesis to the given AppendableExt if disableParens is
true , otherwise does nothing. |
protected void |
collectSchemaObjects(ValidationContext vContext)
Used during Query.validate() calls to collect the dbschema objects
referenced in a query.
|
static BinaryCondition |
equalTo(Object value1,
Object value2)
Convenience method for generating a Condition for testing if a column
is equal to another column.
|
static String |
escapeLikeLiteral(String literal,
char escapeChar)
Escapes the special chars '%', '_', and the given char itself in the
given literal string using the given escape character.
|
static BinaryCondition |
greaterThan(Object value1,
Object value2)
Convenience method for generating a Condition for testing if a column
is strictly greater than a given value.
|
static BinaryCondition |
greaterThan(Object value1,
Object value2,
boolean inclusive)
Convenience method for generating a Condition for testing if a column
is greater than a given value (inclusive or exclusive).
|
static BinaryCondition |
greaterThanOrEq(Object value1,
Object value2)
Convenience method for generating a Condition for testing if a column
is greater than or equal to a given value.
|
boolean |
hasParens()
Returns
true iff the output of this instance would include
surrounding parentheses, false otherwise. |
protected static boolean |
hasParens(SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses)
Determines if any of the given clauses are non-empty.
|
boolean |
isDisableParens()
Returns whether or not wrapping parentheses are disabled for this clause
(for clauses which utilize wrapping parentheses).
|
boolean |
isEmpty()
Returns
true iff the output of this instance would be an
empty expression, false otherwise. |
static BinaryCondition |
lessThan(Object value1,
Object value2)
Convenience method for generating a Condition for testing if a column
is strictly less than another column.
|
static BinaryCondition |
lessThan(Object value1,
Object value2,
boolean inclusive)
Convenience method for generating a Condition for testing if a column
is less than another column (inclusive or exclusive).
|
static BinaryCondition |
lessThanOrEq(Object value1,
Object value2)
Convenience method for generating a Condition for testing if a column
is less than or equal to another column.
|
static BinaryCondition |
like(Object value1,
Object value2)
Convenience method for generating a Condition for testing if a column
is "like" a given value (sql pattern matching).
|
static BinaryCondition |
notEqualTo(Object value1,
Object value2)
Convenience method for generating a Condition for testing if a column
is not equal to another column.
|
static BinaryCondition |
notLike(Object value1,
Object value2)
Convenience method for generating a Condition for testing if a column
is not "like" a given value (sql pattern matching).
|
protected void |
openParen(AppendableExt app)
Appends an open parenthesis to the given AppendableExt if disableParens is
true , otherwise does nothing. |
BinaryCondition |
setLikeEscapeChar(Character escapeChar)
Sets the escape charactor for a [NOT] LIKE condition pattern.
|
protected boolean |
supportsEscape(Object binaryOp) |
setDisableParens
collectSchemaObjects, doValidate, toString
toString, toString
public BinaryCondition(BinaryCondition.Op binaryOp, SqlObject leftValue, SqlObject rightValue)
public BinaryCondition(BinaryCondition.Op binaryOp, Object leftValue, Object rightValue)
protected void collectSchemaObjects(ValidationContext vContext)
SqlObject
collectSchemaObjects
in class SqlObject
vContext
- handle to the current validation contextprotected boolean supportsEscape(Object binaryOp)
public BinaryCondition setLikeEscapeChar(Character escapeChar)
public void appendTo(AppendableExt app) throws IOException
Appendee
appendTo
in interface Appendee
appendTo
in class AppendeeObject
app
- the AppendableExt to which this class should append itselfIOException
- if the append failspublic static String escapeLikeLiteral(String literal, char escapeChar)
literal
- string to escape as a literal patternescapeChar
- escape character to use to escape the literalpublic static BinaryCondition lessThan(Object value1, Object value2, boolean inclusive)
Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
public static BinaryCondition lessThan(Object value1, Object value2)
Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
public static BinaryCondition lessThanOrEq(Object value1, Object value2)
Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
public static BinaryCondition greaterThan(Object value1, Object value2, boolean inclusive)
Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
public static BinaryCondition greaterThan(Object value1, Object value2)
Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
public static BinaryCondition greaterThanOrEq(Object value1, Object value2)
Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
public static BinaryCondition equalTo(Object value1, Object value2)
Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
public static BinaryCondition notEqualTo(Object value1, Object value2)
Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
public static BinaryCondition like(Object value1, Object value2)
Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
public static BinaryCondition notLike(Object value1, Object value2)
Object
-> SqlObject
conversions handled by
Converter.toColumnSqlObject(Object)
.
public boolean isDisableParens()
false
.public boolean isEmpty()
true
iff the output of this instance would be an
empty expression, false
otherwise.
Default implementation returns false
.
public boolean hasParens()
true
iff the output of this instance would include
surrounding parentheses, false
otherwise.
Default implementation returns !isEmpty() && !isDisableParens()
.
protected static boolean areEmpty(SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses)
false
if at least one clause is non-empty, true
otherwiseprotected static boolean hasParens(SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses)
false
if at least one clause is non-empty, true
otherwiseprotected void openParen(AppendableExt app) throws IOException
true
, otherwise does nothing.IOException
protected void closeParen(AppendableExt app) throws IOException
true
, otherwise does nothing.IOException
protected void appendCustomIfNotNull(AppendableExt app, SqlObject obj) throws IOException
null
and enclosing parens.IOException
protected void appendNestedClauses(AppendableExt app, SqlObjectList<? extends com.healthmarketscience.sqlbuilder.NestableClause> nestedClauses) throws IOException
IOException
Copyright © 2006–2021 OpenHMS. All rights reserved.