public class Predicates extends Object
Most predicate functions follow three-valued logic (true, false, null
)
except where otherwise noted.
ScalarValuedFunction
,
DeriveFields
,
FilterRows
Constructor and Description |
---|
Predicates() |
Modifier and Type | Method and Description |
---|---|
static ScalarValuedFunction |
and(List<ScalarValuedFunction> ps)
Builds a record predicate which is a logical and of the
specified predicates.
|
static ScalarValuedFunction |
and(ScalarValuedFunction... ps)
Builds a record predicate which is a logical and of the
specified predicates.
|
static ScalarValuedFunction |
eq(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds a record predicate which tests the equality of
the specified expressions.
|
static ScalarValuedFunction |
eq(String field,
ScalarValued value)
Builds a record predicate which tests the equality of
the specified field with a known value.
|
static ScalarValuedFunction |
eq(String leftField,
String rightField)
Builds a record predicate which tests the equality of
the specified fields.
|
static List<ScalarValuedFunction> |
getPredicateClauses(ScalarValuedFunction p)
Extracts the predicate clauses from an AND or OR predicate.
|
static ScalarValuedFunction |
gt(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds a record predicate which tests whether a specified
expression is strictly greater than another.
|
static ScalarValuedFunction |
gt(String leftField,
ScalarValued rightValue)
Builds a record predicate which tests whether a field is
strictly greater than a known value.
|
static ScalarValuedFunction |
gt(String leftField,
String rightField)
Builds a record predicate which tests whether a field is
strictly greater than another field.
|
static ScalarValuedFunction |
gte(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds a record predicate which tests whether a specified
expression is greater than or equal to another.
|
static ScalarValuedFunction |
gte(String leftField,
ScalarValued rightValue)
Builds a record predicate which tests whether a field is
greater than or equal to a known value.
|
static ScalarValuedFunction |
gte(String leftField,
String rightField)
Builds a record predicate which tests whether a field is
greater than or equal to another field.
|
static boolean |
isConjunction(ScalarValuedFunction f)
Tests whether the specified function is an AND predicate.
|
static boolean |
isDisjunction(ScalarValuedFunction f)
Tests whether the specified function is an OR predicate.
|
static ScalarValuedFunction |
isFalse(ScalarValuedFunction p)
Builds a record predicate which tests whether the
specified predicate is false.
|
static ScalarValuedFunction |
isNull(ScalarValuedFunction expr)
Builds a record predicate which tests whether the
specified expression evaluates to
null . |
static ScalarValuedFunction |
isNull(String field)
Builds a record predicate which tests whether a record field is
null-valued.
|
static ScalarValuedFunction |
isTrue(ScalarValuedFunction p)
Builds a record predicate which tests whether the
specified predicate is true.
|
static ScalarValuedFunction |
like(ScalarValuedFunction expr,
String pattern)
Builds a record predicate which tests whether the
value of an expression matches a specified SQL LIKE pattern.
|
static ScalarValuedFunction |
like(String field,
String pattern)
Builds a record predicate which tests whether the
value of a field matches a specified SQL LIKE pattern.
|
static String |
likeToRegex(String likePattern)
Converts a SQL LIKE pattern into an equivalent regular expression.
|
static ScalarValuedFunction |
lt(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds a record predicate which tests whether a specified
expression is strictly less than another.
|
static ScalarValuedFunction |
lt(String leftField,
ScalarValued rightValue)
Builds a record predicate which tests whether a field is
strictly less than a known value.
|
static ScalarValuedFunction |
lt(String leftField,
String rightField)
Builds a record predicate which tests whether a field is
strictly less than another field.
|
static ScalarValuedFunction |
lte(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds a record predicate which tests whether a specified
expression is less than or equal to another.
|
static ScalarValuedFunction |
lte(String leftField,
ScalarValued rightValue)
Builds a record predicate which tests whether a field is
less than or equal to a known value.
|
static ScalarValuedFunction |
lte(String leftField,
String rightField)
Builds a record predicate which tests whether a field is
less than or equal to another field.
|
static ScalarValuedFunction |
matches(ScalarValuedFunction expr,
String pattern)
Builds a record predicate which tests whether the
value of an expression matches a specified regular expression.
|
static ScalarValuedFunction |
matches(String field,
String pattern)
Builds a record predicate which tests whether the
value of a field matches a specified regular expression.
|
static ScalarValuedFunction |
neq(ScalarValuedFunction leftExpr,
ScalarValuedFunction rightExpr)
Builds a record predicate which tests the inequality of
the specified expressions.
|
static ScalarValuedFunction |
neq(String field,
ScalarValued value)
Builds a record predicate which tests the inequality of
the specified field with a known value.
|
static ScalarValuedFunction |
neq(String leftField,
String rightField)
Builds a record predicate which tests the inequality of
the specified fields.
|
static ScalarValuedFunction |
not(ScalarValuedFunction p)
Builds a record predicate which is a logical negation of
specified predicate.
|
static ScalarValuedFunction |
notFalse(ScalarValuedFunction p)
Builds a record predicate which tests whether the
specified predicate is not false.
|
static ScalarValuedFunction |
notNull(ScalarValuedFunction expr)
Builds a record predicate which tests whether the
specified expression does not evaluate to
null . |
static ScalarValuedFunction |
notNull(String field)
Builds a record predicate which tests whether a record field is
not null-valued.
|
static ScalarValuedFunction |
notTrue(ScalarValuedFunction p)
Builds a record predicate which tests whether the
specified predicate is not true.
|
static ScalarValuedFunction |
or(List<ScalarValuedFunction> ps)
Builds a record predicate which is a logical or of the
specified predicates.
|
static ScalarValuedFunction |
or(ScalarValuedFunction... ps)
Builds a record predicate which is a logical or of the
specified predicates.
|
public static boolean isConjunction(ScalarValuedFunction f)
f
- the function to testtrue
if the function is an AND;
false
otherwiseand(ScalarValuedFunction...)
public static boolean isDisjunction(ScalarValuedFunction f)
f
- the function to testtrue
if the function is an OR;
false
otherwiseor(ScalarValuedFunction...)
public static List<ScalarValuedFunction> getPredicateClauses(ScalarValuedFunction p)
p
- the predicate to break into constituent clausesIllegalArgumentException
- if the predicate is not an AND
or an ORor(ScalarValuedFunction...)
,
and(ScalarValuedFunction...)
public static ScalarValuedFunction and(ScalarValuedFunction... ps)
true
if all subpredicates evaluate to true
.false
if any subpredicate evaluates to false
.null
otherwise
This version of and
is provided for use in a fluent style
with other static methods producing RecordPredicate
objects,
as illustrated by the following code fragment:
and(eq("field1", "field2"),gt("field1","field3"))
ps
- the predicates to be combinedpublic static ScalarValuedFunction and(List<ScalarValuedFunction> ps)
true
if all subpredicates evaluate to true
.false
if any subpredicate evaluates to false
.null
otherwiseps
- the predicates to be combinedpublic static ScalarValuedFunction or(ScalarValuedFunction... ps)
true
if any subpredicate evaluates to true
.false
if all subpredicates evaluate to false
.null
otherwise
This version of or
is provided for use in a fluent style
with other static methods producing RecordPredicate
objects,
as illustrated by the following code fragment:
or(eq("field1", "field2"),gt("field1","field3"))
ps
- the predicates to be combinedpublic static ScalarValuedFunction or(List<ScalarValuedFunction> ps)
true
if any subpredicate evaluates to true
.false
if all subpredicates evaluate to false
.null
otherwiseps
- the predicates to be combinedpublic static ScalarValuedFunction not(ScalarValuedFunction p)
true
if the given predicate evaluates to false
.false
if the given predicate evaluates to true
.null
otherwisep
- the predicates to be negatedpublic static ScalarValuedFunction isTrue(ScalarValuedFunction p)
true
if the given predicate evaluates to true
.false
otherwisep
- the predicate to be testedpublic static ScalarValuedFunction notTrue(ScalarValuedFunction p)
false
if the given predicate evaluates to true
.true
otherwisep
- the predicate to be testedpublic static ScalarValuedFunction isFalse(ScalarValuedFunction p)
true
if the given predicate evaluates to false
.false
otherwisep
- the predicate to be testedpublic static ScalarValuedFunction notFalse(ScalarValuedFunction p)
false
if the given predicate evaluates to false
.true
otherwisep
- the predicate to be testedpublic static ScalarValuedFunction eq(String leftField, String rightField)
null
.leftField
- the first record field value in the comparisonrightField
- the second record field value in the comparisonpublic static ScalarValuedFunction eq(String field, ScalarValued value)
null
,
so does the predicate.field
- the record field value in the comparisonvalue
- the known value in the comparisonpublic static ScalarValuedFunction eq(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
,
so does the predicate.leftExpr
- the expression producing the left value in
the comparisonrightExpr
- the expression producing the right value in
the comparisonpublic static ScalarValuedFunction neq(String leftField, String rightField)
null
.leftField
- the first record field value in the comparisonrightField
- the second record field value in the comparisonpublic static ScalarValuedFunction neq(String field, ScalarValued value)
null
,
so does the predicate.field
- the record field value in the comparisonvalue
- the known value in the comparisonpublic static ScalarValuedFunction neq(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
,
so does the predicate.leftExpr
- the expression producing the left value in
the comparisonrightExpr
- the expression producing the right value in
the comparisonpublic static ScalarValuedFunction lt(String leftField, String rightField)
null
.leftField
- the record field value on the left side of the comparisonrightField
- the record field value on the right side of the comparisonpublic static ScalarValuedFunction lt(String leftField, ScalarValued rightValue)
null
,
so does the predicate.leftField
- the record field value on the left side of the comparisonrightValue
- the known value on the right side of the comparisonpublic static ScalarValuedFunction lt(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
,
so does the predicate.leftExpr
- the expression producing the left value in
the comparisonrightExpr
- the expression producing the right value in
the comparisonpublic static ScalarValuedFunction gt(String leftField, String rightField)
null
.leftField
- the record field value on the left side of the comparisonrightField
- the record field value on the right side of the comparisonpublic static ScalarValuedFunction gt(String leftField, ScalarValued rightValue)
null
,
so does the predicate.leftField
- the record field value on the left side of the comparisonrightValue
- the known value on the right side of the comparisonpublic static ScalarValuedFunction gt(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
,
so does the predicate.leftExpr
- the expression producing the left value in
the comparisonrightExpr
- the expression producing the right value in
the comparisonpublic static ScalarValuedFunction lte(String leftField, String rightField)
null
.leftField
- the record field value on the left side of the comparisonrightField
- the record field value on the right side of the comparisonpublic static ScalarValuedFunction lte(String leftField, ScalarValued rightValue)
null
,
so does the predicate.leftField
- the record field value on the left side of the comparisonrightValue
- the known value on the right side of the comparisonpublic static ScalarValuedFunction lte(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
,
so does the predicate.leftExpr
- the expression producing the left value in
the comparisonrightExpr
- the expression producing the right value in
the comparisonpublic static ScalarValuedFunction gte(String leftField, String rightField)
null
.leftField
- the record field value on the left side of the comparisonrightField
- the record field value on the right side of the comparisonpublic static ScalarValuedFunction gte(String leftField, ScalarValued rightValue)
null
,
so does the predicate.leftField
- the record field value on the left side of the comparisonrightValue
- the known value on the right side of the comparisonpublic static ScalarValuedFunction gte(ScalarValuedFunction leftExpr, ScalarValuedFunction rightExpr)
null
,
so does the predicate.leftExpr
- the expression producing the left value in
the comparisonrightExpr
- the expression producing the right value in
the comparisonpublic static ScalarValuedFunction isNull(String field)
null
.field
- the record field value to testpublic static ScalarValuedFunction isNull(ScalarValuedFunction expr)
null
.
This predicate never yields null
.expr
- the expression to testpublic static ScalarValuedFunction notNull(String field)
null
.field
- the record field value to testpublic static ScalarValuedFunction notNull(ScalarValuedFunction expr)
null
.
This predicate never yields null
.expr
- the expression to testpublic static ScalarValuedFunction like(String field, String pattern)
null
, so does the predicate.field
- the record field against which to matchpattern
- the string pattern to matchpublic static ScalarValuedFunction like(ScalarValuedFunction expr, String pattern)
null
,
so does the predicate.expr
- the expression to evaluate for the match operationpattern
- the string pattern to matchpublic static String likeToRegex(String likePattern)
%
is converted to .*
_
is converted to .
!
to a ^
likePattern
- the pattern match for the LIKE operationpublic static ScalarValuedFunction matches(String field, String pattern)
null
, so does the predicate.field
- the record field against which to matchpattern
- the string pattern to matchpublic static ScalarValuedFunction matches(ScalarValuedFunction expr, String pattern)
null
,
so does the predicate.expr
- the expression to evaluate for the match operationpattern
- the string pattern to matchCopyright © 2021 Actian Corporation. All rights reserved.