Package org.apache.openjpa.kernel.exps
Interface ExpressionFactory
-
- All Known Implementing Classes:
InMemoryExpressionFactory
,JDBCExpressionFactory
public interface ExpressionFactory
The ExpressionFactory must be implemented by a particular runtime to formExpression
s in its native query language.- Author:
- Abe White
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Value
abs(Value num)
Return a value representing the absolute value of the given one.Value
add(Value num1, Value num2)
Return a value representing the two values added together.Value
all(Value target)
Return an expression representing the given condition.Expression
and(Expression exp1, Expression exp2)
Return the two expressions AND'd together.Value
any(Value target)
Return an expression representing the given condition.Expression
asExpression(Value bool)
Return the given value as an expression.Value
avg(Value num)
Return the average of the given value for all matches.Expression
bindKeyVariable(Value var, Value map)
Bind the given variable to the key set of the given map value.Expression
bindValueVariable(Value var, Value map)
Bind the given variable to the value set of the given map value.Expression
bindVariable(Value var, Value coll)
Bind the given variable to the given collection value.Value
cast(Value obj, java.lang.Class cls)
Cast the value to the given class.Value
coalesceExpression(Value[] val)
Return a coalesce expressionValue
concat(Value str, Value args)
Return a value representing the concatenation of the given target with the given args.Expression
contains(Value coll, Value arg)
Return an expression representing the given condition.Expression
containsKey(Value map, Value arg)
Return an expression representing the given condition.Expression
containsValue(Value map, Value arg)
Return an expression representing the given condition.Value
count(Value obj)
Return the count of the given value for all matches.Value
distinct(Value obj)
Return distinct values of the given value.Value
divide(Value num1, Value num2)
Return a value representing the first value divided by the first one.Expression
emptyExpression()
Return a blank expression; this is used when the filter is empty.Expression
endsWith(Value str1, Value str2)
Return whether the first string ends with the second.Expression
equal(Value v1, Value v2)
Return an expression representing the given condition.Value
generalCaseExpression(Expression[] exp, Value val)
Return a general case expression<T extends java.util.Date>
ValuegetCurrentDate(java.lang.Class<T> dateType)
Return a value representing the current date.<T extends java.util.Date>
ValuegetCurrentTime(java.lang.Class<T> timeType)
Return a value representing the current time.<T extends java.util.Date>
ValuegetCurrentTimestamp(java.lang.Class<T> timestampType)
Return a value representing the current timestamp.Value
getKey(Value val)
Path navigation thru map keyValue
getMapValue(Value map, Value arg)
Return an expression representing the given condition.Value
getNull()
Return a value representing null.Value
getObjectId(Value val)
Return the object id of the given value.Value
getThis()
Return a value representingthis
.Expression
greaterThan(Value v1, Value v2)
Return an expression representing the given condition.Expression
greaterThanEqual(Value v1, Value v2)
Return an expression representing the given condition.Value
index(Value target)
Return an index/position of the given value within a collection/map.Value
indexOf(Value str, Value args)
Return a value representing the indexOf (LOCATE in JPQL) function on the given target with the given args.Expression
isEmpty(Value target)
Return an expression representing the given condition.Expression
isInstance(Value obj, java.lang.Class c)
Return whether the first value is an instance of the given class.Expression
isNotEmpty(Value target)
Return an expression representing the given condition.boolean
isVerticalType(Value val)
Return true if the Value is a Type expression and the Type uses joined table strategy.Expression
lessThan(Value v1, Value v2)
Return an expression representing the given condition.Expression
lessThanEqual(Value v1, Value v2)
Return an expression representing the given condition.Value
mapEntry(Value key, Value val)
Return the map entry of the given value.Value
mapKey(Value key, Value val)
Return the map key of the given valueExpression
matches(Value str, Value regexp, java.lang.String single, java.lang.String multi, java.lang.String escape)
Return whether the string matches the matching pattern.Value
max(Value num)
Return the max of the given value for all matches.Value
min(Value num)
Return the max of the given value for all matches.Value
mod(Value num1, Value num2)
Return a value representing the first value mod'd by the second one.Value
multiply(Value num1, Value num2)
Return a value representing the two values multiplied together.Value
newAggregate(AggregateListener listener, Value args)
Return the value of the given function.Arguments
newArgumentList(Value... values)
Return a function argument list consisting of the given values, any of which may itself be an argument list.Arguments
newArgumentList(Value arg1, Value arg2)
Return a function argument list consisting of the given values, either of which may itself be an argument list.Value
newBoundVariable(java.lang.String name, java.lang.Class type)
This method will be called only once per variable bound in acontains
clause, and the returned value will be reused for any further instances of the variable in subexpression of the filter string.Parameter
newCollectionValuedParameter(java.lang.Object name, java.lang.Class type)
Return a value representing a collection-valued parameter.Value
newExtension(FilterListener listener, Value target, Value args)
Return the value of the given extension.Value
newFunction(java.lang.String functionName, java.lang.Class<?> resultType, Value... args)
Return a value representing the given datastore function with the given arguments.Literal
newLiteral(java.lang.Object val, int parseType)
Return a value representing the given constant, which will be aNumber
,String
, orBoolean
instance.Parameter
newParameter(java.lang.Object name, java.lang.Class type)
Return a value representing a parameter for the given value.Path
newPath()
Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the candidate class.
Example:parent.address.city
Path
newPath(Value val)
Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the given value.
Example:var.address.city
Subquery
newSubquery(ClassMetaData candidate, boolean subs, java.lang.String alias)
Return a subquery.Literal
newTypeLiteral(java.lang.Object val, int parseType)
Return a value representing the given constant, which will be aNumber
,String
, orBoolean
instance.Value
newUnboundVariable(java.lang.String name, java.lang.Class type)
Return an unbound variable.Expression
not(Expression exp)
Return the inverse of this expression.Expression
notEqual(Value v1, Value v2)
Return an expression representing the given condition.Expression
notMatches(Value str, Value regexp, java.lang.String single, java.lang.String multi, java.lang.String escape)
Return whether the string does not match the given pattern.Value
nullIfExpression(Value val1, Value val2)
Return a nullif expressionExpression
or(Expression exp1, Expression exp2)
Return the two expressions OR'd together.Value
simpleCaseExpression(Value caseOperand, Expression[] exp, Value val)
Return a simple case expressionValue
size(Value target)
Return an expression representing the given condition.Value
sqrt(Value num)
Return the square root of the given value.Expression
startsWith(Value str1, Value str2)
Return whether the first string starts with the second.Value
stringLength(Value str)
Returns the number of characters in the String value.Value
substring(Value str, Value args)
Return a value representing the substring function on the given target with the given args.Value
subtract(Value num1, Value num2)
Return a value representing the second value subtracted from the first.Value
sum(Value num)
Return the max of the given value for all matches.Value
toLowerCase(Value str)
Return the upper case of the given value.Value
toUpperCase(Value str)
Return the upper case of the given value.Value
trim(Value str, Value trimChar, java.lang.Boolean where)
Trims the specified specified trimChar from the specified value.Value
type(Value target)
Return the type/class of the given value.Expression
whenCondition(Expression exp, Value val)
Return a when condidional clauseExpression
whenScalar(Value val1, Value val2)
Return a when scalar_expression clause
-
-
-
Method Detail
-
emptyExpression
Expression emptyExpression()
Return a blank expression; this is used when the filter is empty.
-
asExpression
Expression asExpression(Value bool)
Return the given value as an expression.
-
equal
Expression equal(Value v1, Value v2)
Return an expression representing the given condition.
-
notEqual
Expression notEqual(Value v1, Value v2)
Return an expression representing the given condition.
-
lessThan
Expression lessThan(Value v1, Value v2)
Return an expression representing the given condition.
-
greaterThan
Expression greaterThan(Value v1, Value v2)
Return an expression representing the given condition.
-
lessThanEqual
Expression lessThanEqual(Value v1, Value v2)
Return an expression representing the given condition.
-
greaterThanEqual
Expression greaterThanEqual(Value v1, Value v2)
Return an expression representing the given condition.
-
isEmpty
Expression isEmpty(Value target)
Return an expression representing the given condition.
-
isNotEmpty
Expression isNotEmpty(Value target)
Return an expression representing the given condition.
-
contains
Expression contains(Value coll, Value arg)
Return an expression representing the given condition.
-
containsKey
Expression containsKey(Value map, Value arg)
Return an expression representing the given condition.
-
containsValue
Expression containsValue(Value map, Value arg)
Return an expression representing the given condition.
-
getMapValue
Value getMapValue(Value map, Value arg)
Return an expression representing the given condition.
-
isInstance
Expression isInstance(Value obj, java.lang.Class c)
Return whether the first value is an instance of the given class.
-
and
Expression and(Expression exp1, Expression exp2)
Return the two expressions AND'd together.
-
or
Expression or(Expression exp1, Expression exp2)
Return the two expressions OR'd together.
-
not
Expression not(Expression exp)
Return the inverse of this expression.
-
bindVariable
Expression bindVariable(Value var, Value coll)
Bind the given variable to the given collection value.
-
bindKeyVariable
Expression bindKeyVariable(Value var, Value map)
Bind the given variable to the key set of the given map value.
-
bindValueVariable
Expression bindValueVariable(Value var, Value map)
Bind the given variable to the value set of the given map value.
-
endsWith
Expression endsWith(Value str1, Value str2)
Return whether the first string ends with the second.
-
matches
Expression matches(Value str, Value regexp, java.lang.String single, java.lang.String multi, java.lang.String escape)
Return whether the string matches the matching pattern.- Parameters:
str
- the value to compareregexp
- the pattern against which to comparesingle
- the token that signifies a single-character matchmulti
- the token that signifies a multi-character matchescape
- the escape token that escapes the matching tokens
-
notMatches
Expression notMatches(Value str, Value regexp, java.lang.String single, java.lang.String multi, java.lang.String escape)
Return whether the string does not match the given pattern.- Parameters:
str
- the value to compareregexp
- the pattern against which to comparesingle
- the token that signifies a single-character matchmulti
- the token that signifies a multi-character matchescape
- the escape token that escapes the matching tokens
-
startsWith
Expression startsWith(Value str1, Value str2)
Return whether the first string starts with the second.
-
trim
Value trim(Value str, Value trimChar, java.lang.Boolean where)
Trims the specified specified trimChar from the specified value.- Parameters:
str
- the value from which to trimtrimChar
- the characters to trim offwhere
- which side of the String to trim: null indicates both sides, true indicates leading, and false indicates trailing
-
newSubquery
Subquery newSubquery(ClassMetaData candidate, boolean subs, java.lang.String alias)
Return a subquery. Paths for the candidates of the subquery are created withnewPath(Value)
, passing in the subquery as the value.- Parameters:
candidate
- the candidate class of the subquerysubs
- whether the query includes subclassesalias
- the alias given to the query candidate class
-
newPath
Path newPath()
Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the candidate class.
Example:parent.address.city
-
newPath
Path newPath(Value val)
Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the given value.
Example:var.address.city
-
newLiteral
Literal newLiteral(java.lang.Object val, int parseType)
Return a value representing the given constant, which will be aNumber
,String
, orBoolean
instance.
-
getThis
Value getThis()
Return a value representingthis
.
-
getNull
Value getNull()
Return a value representing null.
-
getCurrentDate
<T extends java.util.Date> Value getCurrentDate(java.lang.Class<T> dateType)
Return a value representing the current date.
-
getCurrentTime
<T extends java.util.Date> Value getCurrentTime(java.lang.Class<T> timeType)
Return a value representing the current time.
-
getCurrentTimestamp
<T extends java.util.Date> Value getCurrentTimestamp(java.lang.Class<T> timestampType)
Return a value representing the current timestamp.
-
newParameter
Parameter newParameter(java.lang.Object name, java.lang.Class type)
Return a value representing a parameter for the given value. The type may beObject
if the parameter is not declared.
-
newCollectionValuedParameter
Parameter newCollectionValuedParameter(java.lang.Object name, java.lang.Class type)
Return a value representing a collection-valued parameter. The type may beObject
if the parameter is not declared.
-
newExtension
Value newExtension(FilterListener listener, Value target, Value args)
Return the value of the given extension.
-
newAggregate
Value newAggregate(AggregateListener listener, Value args)
Return the value of the given function.
-
newArgumentList
Arguments newArgumentList(Value arg1, Value arg2)
Return a function argument list consisting of the given values, either of which may itself be an argument list.
-
newArgumentList
Arguments newArgumentList(Value... values)
Return a function argument list consisting of the given values, any of which may itself be an argument list.
-
newUnboundVariable
Value newUnboundVariable(java.lang.String name, java.lang.Class type)
Return an unbound variable. This method will only be called once for a given named unbound variable. The type may beObject
if the variable is not declared.
-
newBoundVariable
Value newBoundVariable(java.lang.String name, java.lang.Class type)
This method will be called only once per variable bound in acontains
clause, and the returned value will be reused for any further instances of the variable in subexpression of the filter string. The type may beObject
if the variable is not declared.
-
subtract
Value subtract(Value num1, Value num2)
Return a value representing the second value subtracted from the first.
-
multiply
Value multiply(Value num1, Value num2)
Return a value representing the two values multiplied together.
-
divide
Value divide(Value num1, Value num2)
Return a value representing the first value divided by the first one.
-
mod
Value mod(Value num1, Value num2)
Return a value representing the first value mod'd by the second one.
-
indexOf
Value indexOf(Value str, Value args)
Return a value representing the indexOf (LOCATE in JPQL) function on the given target with the given args. The optional second argument is one-based.
-
concat
Value concat(Value str, Value args)
Return a value representing the concatenation of the given target with the given args.
-
substring
Value substring(Value str, Value args)
Return a value representing the substring function on the given target with the given args. Unlike as withString.substring(int)
, the start index is one-based, and the second argument is the length.
-
size
Value size(Value target)
Return an expression representing the given condition.- Since:
- 0.4.0.0
-
index
Value index(Value target)
Return an index/position of the given value within a collection/map.- Since:
- 2.0.0
-
mapEntry
Value mapEntry(Value key, Value val)
Return the map entry of the given value.- Since:
- 2.0.0
-
distinct
Value distinct(Value obj)
Return distinct values of the given value. This is typically used within aggregates, for example: max(distinct(path))- Since:
- 0.4.0.0
-
simpleCaseExpression
Value simpleCaseExpression(Value caseOperand, Expression[] exp, Value val)
Return a simple case expression
-
generalCaseExpression
Value generalCaseExpression(Expression[] exp, Value val)
Return a general case expression
-
whenCondition
Expression whenCondition(Expression exp, Value val)
Return a when condidional clause
-
whenScalar
Expression whenScalar(Value val1, Value val2)
Return a when scalar_expression clause
-
newTypeLiteral
Literal newTypeLiteral(java.lang.Object val, int parseType)
Return a value representing the given constant, which will be aNumber
,String
, orBoolean
instance.
-
newFunction
Value newFunction(java.lang.String functionName, java.lang.Class<?> resultType, Value... args)
Return a value representing the given datastore function with the given arguments.
-
isVerticalType
boolean isVerticalType(Value val)
Return true if the Value is a Type expression and the Type uses joined table strategy.
-
-