Package org.apache.openjpa.kernel.exps
Class InMemoryExpressionFactory
java.lang.Object
org.apache.openjpa.kernel.exps.InMemoryExpressionFactory
- All Implemented Interfaces:
ExpressionFactory
Expression factory implementation that can be used to execute queries
in memory.
- Author:
- Abe White
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionReturn a value representing the absolute value of the given one.Return a value representing the two values added together.Return an expression representing the given condition.and
(Expression exp1, Expression exp2) Return the two expressions AND'd together.Return an expression representing the given condition.Return the given value as an expression.Return the average of the given value for all matches.bindKeyVariable
(Value var, Value val) Bind the given variable to the key set of the given map value.bindValueVariable
(Value var, Value val) Bind the given variable to the value set of the given map value.bindVariable
(Value var, Value val) Bind the given variable to the given collection value.Cast the value to the given class.coalesceExpression
(Value[] val) Return a coalesce expressionReturn a value representing the concatenation of the given target with the given args.Return an expression representing the given condition.containsKey
(Value v1, Value v2) Return an expression representing the given condition.containsValue
(Value v1, Value v2) Return an expression representing the given condition.Return the count of the given value for all matches.distinct
(QueryExpressions exps, boolean fromExtent, List matches) Filter the given list of matches, removing duplicate entries.Return distinct values of the given value.Return a value representing the first value divided by the first one.Return a blank expression; this is used when the filter is empty.Return whether the first string ends with the second.Return an expression representing the given condition.generalCaseExpression
(Expression[] exp, Value val) Return a general case expressiongetCurrentDate
(Class<T> dateType) Return a value representing the current date.getCurrentTime
(Class<T> dateType) Return a value representing the current time.getCurrentTimestamp
(Class<T> dateType) Return a value representing the current timestamp.Path navigation thru map keygetMapValue
(Value map, Value arg) Return an expression representing the given condition.getNull()
Return a value representing null.getObjectId
(Value val) Return the object id of the given value.getThis()
Return a value representingthis
.greaterThan
(Value v1, Value v2) Return an expression representing the given condition.greaterThanEqual
(Value v1, Value v2) Return an expression representing the given condition.group
(QueryExpressions exps, List matches, StoreContext ctx, Object[] params) Group the list of matches into a list of lists.Return an index/position of the given value within a collection/map.Return a value representing the indexOf (LOCATE in JPQL) function on the given target with the given args.Return an expression representing the given condition.isInstance
(Value v1, Class c) Return whether the first value is an instance of the given class.isNotEmpty
(Value v1) 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.Return an expression representing the given condition.lessThanEqual
(Value v1, Value v2) Return an expression representing the given condition.Return the map entry of the given value.Return the map key of the given valueprotected boolean
matches
(Exp exp, Object candidate, StoreContext ctx, Object[] params, int i) Recursive method to evaluate the expression for all possible combinations of unbound variables.boolean
matches
(QueryExpressions exps, Collection group, StoreContext ctx, Object[] params) Return true if the given group matches the having expression.boolean
matches
(QueryExpressions exps, ClassMetaData type, boolean subs, Object candidate, StoreContext ctx, Object[] params) Tests whether the given candidate matches the given type and this expression.Return whether the string matches the matching pattern.Return the max of the given value for all matches.Return the max of the given value for all matches.Return a value representing the first value mod'd by the second one.Return a value representing the two values multiplied together.newAggregate
(AggregateListener listener, Value arg) Return the value of the given function.newArgumentList
(Value... values) Return a function argument list consisting of the given values, any of which may itself be an argument list.newArgumentList
(Value val1, Value val2) Return a function argument list consisting of the given values, either of which may itself be an argument list.newBoundVariable
(String name, 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.newCollectionValuedParameter
(Object name, Class type) Return a value representing a collection-valued parameter.newExtension
(FilterListener listener, Value target, Value arg) Return the value of the given extension.newFunction
(String functionName, Class<?> resultType, Value... args) Return a value representing the given datastore function with the given arguments.newLiteral
(Object val, int parseType) newParameter
(Object name, Class type) Return a value representing a parameter for the given value.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
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
newSubquery
(ClassMetaData candidate, boolean subs, String alias) Return a subquery.newTypeLiteral
(Object val, int parseType) newUnboundVariable
(String name, Class type) Return an unbound variable.not
(Expression exp) Return the inverse of this expression.Return an expression representing the given condition.Return whether the string does not match the given pattern.nullIfExpression
(Value val1, Value val2) Return a nullif expressionor
(Expression exp1, Expression exp2) Return the two expressions OR'd together.order
(QueryExpressions exps, List matches, StoreContext ctx, Object[] params) Order the given list of matches on the given value.project
(QueryExpressions exps, List matches, StoreContext ctx, Object[] params) Create the projections for the given results.simpleCaseExpression
(Value caseOperand, Expression[] exp, Value val) Return a simple case expressionReturn an expression representing the given condition.Return the square root of the given value.startsWith
(Value v1, Value v2) Return whether the first string starts with the second.stringLength
(Value str) Returns the number of characters in the String value.Return a value representing the substring function on the given target with the given args.Return a value representing the second value subtracted from the first.Return the max of the given value for all matches.toLowerCase
(Value val) Return the upper case of the given value.toUpperCase
(Value val) Return the upper case of the given value.Trims the specified specified trimChar from the specified value.Return the type/class of the given value.whenCondition
(Expression exp, Value val) Return a when condidional clausewhenScalar
(Value val1, Value val2) Return a when scalar_expression clause
-
Constructor Details
-
InMemoryExpressionFactory
public InMemoryExpressionFactory()
-
-
Method Details
-
matches
public boolean matches(QueryExpressions exps, ClassMetaData type, boolean subs, Object candidate, StoreContext ctx, Object[] params) Tests whether the given candidate matches the given type and this expression. -
matches
Recursive method to evaluate the expression for all possible combinations of unbound variables. This method simulates a sequence of embedded procedural loops over the extents of all variables in the unbounds list. -
group
Group the list of matches into a list of lists. -
matches
Return true if the given group matches the having expression. -
project
Create the projections for the given results. -
order
Order the given list of matches on the given value. -
distinct
Filter the given list of matches, removing duplicate entries. -
emptyExpression
Description copied from interface:ExpressionFactory
Return a blank expression; this is used when the filter is empty.- Specified by:
emptyExpression
in interfaceExpressionFactory
-
asExpression
Description copied from interface:ExpressionFactory
Return the given value as an expression.- Specified by:
asExpression
in interfaceExpressionFactory
-
equal
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
equal
in interfaceExpressionFactory
-
notEqual
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
notEqual
in interfaceExpressionFactory
-
lessThan
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
lessThan
in interfaceExpressionFactory
-
greaterThan
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
greaterThan
in interfaceExpressionFactory
-
lessThanEqual
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
lessThanEqual
in interfaceExpressionFactory
-
greaterThanEqual
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
greaterThanEqual
in interfaceExpressionFactory
-
isEmpty
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
isEmpty
in interfaceExpressionFactory
-
isNotEmpty
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
isNotEmpty
in interfaceExpressionFactory
-
contains
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
contains
in interfaceExpressionFactory
-
containsKey
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
containsKey
in interfaceExpressionFactory
-
containsValue
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
containsValue
in interfaceExpressionFactory
-
getMapValue
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
getMapValue
in interfaceExpressionFactory
-
isInstance
Description copied from interface:ExpressionFactory
Return whether the first value is an instance of the given class.- Specified by:
isInstance
in interfaceExpressionFactory
-
and
Description copied from interface:ExpressionFactory
Return the two expressions AND'd together.- Specified by:
and
in interfaceExpressionFactory
-
or
Description copied from interface:ExpressionFactory
Return the two expressions OR'd together.- Specified by:
or
in interfaceExpressionFactory
-
not
Description copied from interface:ExpressionFactory
Return the inverse of this expression.- Specified by:
not
in interfaceExpressionFactory
-
bindVariable
Description copied from interface:ExpressionFactory
Bind the given variable to the given collection value.- Specified by:
bindVariable
in interfaceExpressionFactory
-
bindKeyVariable
Description copied from interface:ExpressionFactory
Bind the given variable to the key set of the given map value.- Specified by:
bindKeyVariable
in interfaceExpressionFactory
-
bindValueVariable
Description copied from interface:ExpressionFactory
Bind the given variable to the value set of the given map value.- Specified by:
bindValueVariable
in interfaceExpressionFactory
-
endsWith
Description copied from interface:ExpressionFactory
Return whether the first string ends with the second.- Specified by:
endsWith
in interfaceExpressionFactory
-
matches
Description copied from interface:ExpressionFactory
Return whether the string matches the matching pattern.- Specified by:
matches
in interfaceExpressionFactory
- Parameters:
v1
- the value to comparev2
- the pattern against which to comparesingle
- the token that signifies a single-character matchmulti
- the token that signifies a multi-character matchesc
- the escape token that escapes the matching tokens
-
notMatches
Description copied from interface:ExpressionFactory
Return whether the string does not match the given pattern.- Specified by:
notMatches
in interfaceExpressionFactory
- Parameters:
v1
- the value to comparev2
- the pattern against which to comparesingle
- the token that signifies a single-character matchmulti
- the token that signifies a multi-character matchesc
- the escape token that escapes the matching tokens
-
startsWith
Description copied from interface:ExpressionFactory
Return whether the first string starts with the second.- Specified by:
startsWith
in interfaceExpressionFactory
-
newSubquery
Description copied from interface:ExpressionFactory
Return a subquery. Paths for the candidates of the subquery are created withExpressionFactory.newPath(Value)
, passing in the subquery as the value.- Specified by:
newSubquery
in interfaceExpressionFactory
- Parameters:
candidate
- the candidate class of the subquerysubs
- whether the query includes subclassesalias
- the alias given to the query candidate class
-
newPath
Description copied from interface:ExpressionFactory
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
- Specified by:
newPath
in interfaceExpressionFactory
-
newPath
Description copied from interface:ExpressionFactory
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
- Specified by:
newPath
in interfaceExpressionFactory
-
newLiteral
Description copied from interface:ExpressionFactory
Return a value representing the given constant, which will be aNumber
,String
, orBoolean
instance.- Specified by:
newLiteral
in interfaceExpressionFactory
-
newTypeLiteral
Description copied from interface:ExpressionFactory
Return a value representing the given constant, which will be aNumber
,String
, orBoolean
instance.- Specified by:
newTypeLiteral
in interfaceExpressionFactory
-
getThis
Description copied from interface:ExpressionFactory
Return a value representingthis
.- Specified by:
getThis
in interfaceExpressionFactory
-
getNull
Description copied from interface:ExpressionFactory
Return a value representing null.- Specified by:
getNull
in interfaceExpressionFactory
-
getCurrentDate
Description copied from interface:ExpressionFactory
Return a value representing the current date.- Specified by:
getCurrentDate
in interfaceExpressionFactory
-
getCurrentTime
Description copied from interface:ExpressionFactory
Return a value representing the current time.- Specified by:
getCurrentTime
in interfaceExpressionFactory
-
getCurrentTimestamp
Description copied from interface:ExpressionFactory
Return a value representing the current timestamp.- Specified by:
getCurrentTimestamp
in interfaceExpressionFactory
-
newParameter
Description copied from interface:ExpressionFactory
Return a value representing a parameter for the given value. The type may beObject
if the parameter is not declared.- Specified by:
newParameter
in interfaceExpressionFactory
-
newCollectionValuedParameter
Description copied from interface:ExpressionFactory
Return a value representing a collection-valued parameter. The type may beObject
if the parameter is not declared.- Specified by:
newCollectionValuedParameter
in interfaceExpressionFactory
-
newExtension
Description copied from interface:ExpressionFactory
Return the value of the given extension.- Specified by:
newExtension
in interfaceExpressionFactory
-
newAggregate
Description copied from interface:ExpressionFactory
Return the value of the given function.- Specified by:
newAggregate
in interfaceExpressionFactory
-
newArgumentList
Description copied from interface:ExpressionFactory
Return a function argument list consisting of the given values, either of which may itself be an argument list.- Specified by:
newArgumentList
in interfaceExpressionFactory
-
newArgumentList
Description copied from interface:ExpressionFactory
Return a function argument list consisting of the given values, any of which may itself be an argument list.- Specified by:
newArgumentList
in interfaceExpressionFactory
-
newUnboundVariable
Description copied from interface:ExpressionFactory
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.- Specified by:
newUnboundVariable
in interfaceExpressionFactory
-
newBoundVariable
Description copied from interface:ExpressionFactory
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.- Specified by:
newBoundVariable
in interfaceExpressionFactory
-
cast
Description copied from interface:ExpressionFactory
Cast the value to the given class.- Specified by:
cast
in interfaceExpressionFactory
-
add
Description copied from interface:ExpressionFactory
Return a value representing the two values added together.- Specified by:
add
in interfaceExpressionFactory
-
subtract
Description copied from interface:ExpressionFactory
Return a value representing the second value subtracted from the first.- Specified by:
subtract
in interfaceExpressionFactory
-
multiply
Description copied from interface:ExpressionFactory
Return a value representing the two values multiplied together.- Specified by:
multiply
in interfaceExpressionFactory
-
divide
Description copied from interface:ExpressionFactory
Return a value representing the first value divided by the first one.- Specified by:
divide
in interfaceExpressionFactory
-
mod
Description copied from interface:ExpressionFactory
Return a value representing the first value mod'd by the second one.- Specified by:
mod
in interfaceExpressionFactory
-
abs
Description copied from interface:ExpressionFactory
Return a value representing the absolute value of the given one.- Specified by:
abs
in interfaceExpressionFactory
-
indexOf
Description copied from interface:ExpressionFactory
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.- Specified by:
indexOf
in interfaceExpressionFactory
-
concat
Description copied from interface:ExpressionFactory
Return a value representing the concatenation of the given target with the given args.- Specified by:
concat
in interfaceExpressionFactory
-
stringLength
Description copied from interface:ExpressionFactory
Returns the number of characters in the String value.- Specified by:
stringLength
in interfaceExpressionFactory
-
trim
Description copied from interface:ExpressionFactory
Trims the specified specified trimChar from the specified value.- Specified by:
trim
in interfaceExpressionFactory
- 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
-
sqrt
Description copied from interface:ExpressionFactory
Return the square root of the given value.- Specified by:
sqrt
in interfaceExpressionFactory
-
substring
Description copied from interface:ExpressionFactory
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.- Specified by:
substring
in interfaceExpressionFactory
-
toUpperCase
Description copied from interface:ExpressionFactory
Return the upper case of the given value.- Specified by:
toUpperCase
in interfaceExpressionFactory
-
toLowerCase
Description copied from interface:ExpressionFactory
Return the upper case of the given value.- Specified by:
toLowerCase
in interfaceExpressionFactory
-
avg
Description copied from interface:ExpressionFactory
Return the average of the given value for all matches.- Specified by:
avg
in interfaceExpressionFactory
-
count
Description copied from interface:ExpressionFactory
Return the count of the given value for all matches.- Specified by:
count
in interfaceExpressionFactory
-
distinct
Description copied from interface:ExpressionFactory
Return distinct values of the given value. This is typically used within aggregates, for example: max(distinct(path))- Specified by:
distinct
in interfaceExpressionFactory
-
max
Description copied from interface:ExpressionFactory
Return the max of the given value for all matches.- Specified by:
max
in interfaceExpressionFactory
-
min
Description copied from interface:ExpressionFactory
Return the max of the given value for all matches.- Specified by:
min
in interfaceExpressionFactory
-
sum
Description copied from interface:ExpressionFactory
Return the max of the given value for all matches.- Specified by:
sum
in interfaceExpressionFactory
-
any
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
any
in interfaceExpressionFactory
-
all
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
all
in interfaceExpressionFactory
-
size
Description copied from interface:ExpressionFactory
Return an expression representing the given condition.- Specified by:
size
in interfaceExpressionFactory
-
index
Description copied from interface:ExpressionFactory
Return an index/position of the given value within a collection/map.- Specified by:
index
in interfaceExpressionFactory
-
type
Description copied from interface:ExpressionFactory
Return the type/class of the given value.- Specified by:
type
in interfaceExpressionFactory
-
mapEntry
Description copied from interface:ExpressionFactory
Return the map entry of the given value.- Specified by:
mapEntry
in interfaceExpressionFactory
-
mapKey
Description copied from interface:ExpressionFactory
Return the map key of the given value- Specified by:
mapKey
in interfaceExpressionFactory
-
getKey
Description copied from interface:ExpressionFactory
Path navigation thru map key- Specified by:
getKey
in interfaceExpressionFactory
-
getObjectId
Description copied from interface:ExpressionFactory
Return the object id of the given value.- Specified by:
getObjectId
in interfaceExpressionFactory
-
generalCaseExpression
Description copied from interface:ExpressionFactory
Return a general case expression- Specified by:
generalCaseExpression
in interfaceExpressionFactory
-
simpleCaseExpression
Description copied from interface:ExpressionFactory
Return a simple case expression- Specified by:
simpleCaseExpression
in interfaceExpressionFactory
-
whenCondition
Description copied from interface:ExpressionFactory
Return a when condidional clause- Specified by:
whenCondition
in interfaceExpressionFactory
-
whenScalar
Description copied from interface:ExpressionFactory
Return a when scalar_expression clause- Specified by:
whenScalar
in interfaceExpressionFactory
-
coalesceExpression
Description copied from interface:ExpressionFactory
Return a coalesce expression- Specified by:
coalesceExpression
in interfaceExpressionFactory
-
nullIfExpression
Description copied from interface:ExpressionFactory
Return a nullif expression- Specified by:
nullIfExpression
in interfaceExpressionFactory
-
newFunction
Description copied from interface:ExpressionFactory
Return a value representing the given datastore function with the given arguments.- Specified by:
newFunction
in interfaceExpressionFactory
-
isVerticalType
Description copied from interface:ExpressionFactory
Return true if the Value is a Type expression and the Type uses joined table strategy.- Specified by:
isVerticalType
in interfaceExpressionFactory
-