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
Constructors -
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.booleanisVerticalType(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 booleanmatches(Exp exp, Object candidate, StoreContext ctx, Object[] params, int i) Recursive method to evaluate the expression for all possible combinations of unbound variables.booleanmatches(QueryExpressions exps, Collection group, StoreContext ctx, Object[] params) Return true if the given group matches the having expression.booleanmatches(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 acontainsclause, 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.cityReturn 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.citynewSubquery(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:ExpressionFactoryReturn a blank expression; this is used when the filter is empty.- Specified by:
emptyExpressionin interfaceExpressionFactory
-
asExpression
Description copied from interface:ExpressionFactoryReturn the given value as an expression.- Specified by:
asExpressionin interfaceExpressionFactory
-
equal
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
equalin interfaceExpressionFactory
-
notEqual
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
notEqualin interfaceExpressionFactory
-
lessThan
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
lessThanin interfaceExpressionFactory
-
greaterThan
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
greaterThanin interfaceExpressionFactory
-
lessThanEqual
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
lessThanEqualin interfaceExpressionFactory
-
greaterThanEqual
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
greaterThanEqualin interfaceExpressionFactory
-
isEmpty
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
isEmptyin interfaceExpressionFactory
-
isNotEmpty
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
isNotEmptyin interfaceExpressionFactory
-
contains
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
containsin interfaceExpressionFactory
-
containsKey
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
containsKeyin interfaceExpressionFactory
-
containsValue
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
containsValuein interfaceExpressionFactory
-
getMapValue
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
getMapValuein interfaceExpressionFactory
-
isInstance
Description copied from interface:ExpressionFactoryReturn whether the first value is an instance of the given class.- Specified by:
isInstancein interfaceExpressionFactory
-
and
Description copied from interface:ExpressionFactoryReturn the two expressions AND'd together.- Specified by:
andin interfaceExpressionFactory
-
or
Description copied from interface:ExpressionFactoryReturn the two expressions OR'd together.- Specified by:
orin interfaceExpressionFactory
-
not
Description copied from interface:ExpressionFactoryReturn the inverse of this expression.- Specified by:
notin interfaceExpressionFactory
-
bindVariable
Description copied from interface:ExpressionFactoryBind the given variable to the given collection value.- Specified by:
bindVariablein interfaceExpressionFactory
-
bindKeyVariable
Description copied from interface:ExpressionFactoryBind the given variable to the key set of the given map value.- Specified by:
bindKeyVariablein interfaceExpressionFactory
-
bindValueVariable
Description copied from interface:ExpressionFactoryBind the given variable to the value set of the given map value.- Specified by:
bindValueVariablein interfaceExpressionFactory
-
endsWith
Description copied from interface:ExpressionFactoryReturn whether the first string ends with the second.- Specified by:
endsWithin interfaceExpressionFactory
-
matches
Description copied from interface:ExpressionFactoryReturn whether the string matches the matching pattern.- Specified by:
matchesin 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:ExpressionFactoryReturn whether the string does not match the given pattern.- Specified by:
notMatchesin 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:ExpressionFactoryReturn whether the first string starts with the second.- Specified by:
startsWithin interfaceExpressionFactory
-
newSubquery
Description copied from interface:ExpressionFactoryReturn a subquery. Paths for the candidates of the subquery are created withExpressionFactory.newPath(Value), passing in the subquery as the value.- Specified by:
newSubqueryin 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:ExpressionFactoryReturn 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:
newPathin interfaceExpressionFactory
-
newPath
Description copied from interface:ExpressionFactoryReturn 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:
newPathin interfaceExpressionFactory
-
newLiteral
Description copied from interface:ExpressionFactoryReturn a value representing the given constant, which will be aNumber,String, orBooleaninstance.- Specified by:
newLiteralin interfaceExpressionFactory
-
newTypeLiteral
Description copied from interface:ExpressionFactoryReturn a value representing the given constant, which will be aNumber,String, orBooleaninstance.- Specified by:
newTypeLiteralin interfaceExpressionFactory
-
getThis
Description copied from interface:ExpressionFactoryReturn a value representingthis.- Specified by:
getThisin interfaceExpressionFactory
-
getNull
Description copied from interface:ExpressionFactoryReturn a value representing null.- Specified by:
getNullin interfaceExpressionFactory
-
getCurrentDate
Description copied from interface:ExpressionFactoryReturn a value representing the current date.- Specified by:
getCurrentDatein interfaceExpressionFactory
-
getCurrentTime
Description copied from interface:ExpressionFactoryReturn a value representing the current time.- Specified by:
getCurrentTimein interfaceExpressionFactory
-
getCurrentTimestamp
Description copied from interface:ExpressionFactoryReturn a value representing the current timestamp.- Specified by:
getCurrentTimestampin interfaceExpressionFactory
-
newParameter
Description copied from interface:ExpressionFactoryReturn a value representing a parameter for the given value. The type may beObjectif the parameter is not declared.- Specified by:
newParameterin interfaceExpressionFactory
-
newCollectionValuedParameter
Description copied from interface:ExpressionFactoryReturn a value representing a collection-valued parameter. The type may beObjectif the parameter is not declared.- Specified by:
newCollectionValuedParameterin interfaceExpressionFactory
-
newExtension
Description copied from interface:ExpressionFactoryReturn the value of the given extension.- Specified by:
newExtensionin interfaceExpressionFactory
-
newAggregate
Description copied from interface:ExpressionFactoryReturn the value of the given function.- Specified by:
newAggregatein interfaceExpressionFactory
-
newArgumentList
Description copied from interface:ExpressionFactoryReturn a function argument list consisting of the given values, either of which may itself be an argument list.- Specified by:
newArgumentListin interfaceExpressionFactory
-
newArgumentList
Description copied from interface:ExpressionFactoryReturn a function argument list consisting of the given values, any of which may itself be an argument list.- Specified by:
newArgumentListin interfaceExpressionFactory
-
newUnboundVariable
Description copied from interface:ExpressionFactoryReturn an unbound variable. This method will only be called once for a given named unbound variable. The type may beObjectif the variable is not declared.- Specified by:
newUnboundVariablein interfaceExpressionFactory
-
newBoundVariable
Description copied from interface:ExpressionFactoryThis method will be called only once per variable bound in acontainsclause, and the returned value will be reused for any further instances of the variable in subexpression of the filter string. The type may beObjectif the variable is not declared.- Specified by:
newBoundVariablein interfaceExpressionFactory
-
cast
Description copied from interface:ExpressionFactoryCast the value to the given class.- Specified by:
castin interfaceExpressionFactory
-
add
Description copied from interface:ExpressionFactoryReturn a value representing the two values added together.- Specified by:
addin interfaceExpressionFactory
-
subtract
Description copied from interface:ExpressionFactoryReturn a value representing the second value subtracted from the first.- Specified by:
subtractin interfaceExpressionFactory
-
multiply
Description copied from interface:ExpressionFactoryReturn a value representing the two values multiplied together.- Specified by:
multiplyin interfaceExpressionFactory
-
divide
Description copied from interface:ExpressionFactoryReturn a value representing the first value divided by the first one.- Specified by:
dividein interfaceExpressionFactory
-
mod
Description copied from interface:ExpressionFactoryReturn a value representing the first value mod'd by the second one.- Specified by:
modin interfaceExpressionFactory
-
abs
Description copied from interface:ExpressionFactoryReturn a value representing the absolute value of the given one.- Specified by:
absin interfaceExpressionFactory
-
indexOf
Description copied from interface:ExpressionFactoryReturn 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:
indexOfin interfaceExpressionFactory
-
concat
Description copied from interface:ExpressionFactoryReturn a value representing the concatenation of the given target with the given args.- Specified by:
concatin interfaceExpressionFactory
-
stringLength
Description copied from interface:ExpressionFactoryReturns the number of characters in the String value.- Specified by:
stringLengthin interfaceExpressionFactory
-
trim
Description copied from interface:ExpressionFactoryTrims the specified specified trimChar from the specified value.- Specified by:
trimin 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:ExpressionFactoryReturn the square root of the given value.- Specified by:
sqrtin interfaceExpressionFactory
-
substring
Description copied from interface:ExpressionFactoryReturn 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:
substringin interfaceExpressionFactory
-
toUpperCase
Description copied from interface:ExpressionFactoryReturn the upper case of the given value.- Specified by:
toUpperCasein interfaceExpressionFactory
-
toLowerCase
Description copied from interface:ExpressionFactoryReturn the upper case of the given value.- Specified by:
toLowerCasein interfaceExpressionFactory
-
avg
Description copied from interface:ExpressionFactoryReturn the average of the given value for all matches.- Specified by:
avgin interfaceExpressionFactory
-
count
Description copied from interface:ExpressionFactoryReturn the count of the given value for all matches.- Specified by:
countin interfaceExpressionFactory
-
distinct
Description copied from interface:ExpressionFactoryReturn distinct values of the given value. This is typically used within aggregates, for example: max(distinct(path))- Specified by:
distinctin interfaceExpressionFactory
-
max
Description copied from interface:ExpressionFactoryReturn the max of the given value for all matches.- Specified by:
maxin interfaceExpressionFactory
-
min
Description copied from interface:ExpressionFactoryReturn the max of the given value for all matches.- Specified by:
minin interfaceExpressionFactory
-
sum
Description copied from interface:ExpressionFactoryReturn the max of the given value for all matches.- Specified by:
sumin interfaceExpressionFactory
-
any
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
anyin interfaceExpressionFactory
-
all
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
allin interfaceExpressionFactory
-
size
Description copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
sizein interfaceExpressionFactory
-
index
Description copied from interface:ExpressionFactoryReturn an index/position of the given value within a collection/map.- Specified by:
indexin interfaceExpressionFactory
-
type
Description copied from interface:ExpressionFactoryReturn the type/class of the given value.- Specified by:
typein interfaceExpressionFactory
-
mapEntry
Description copied from interface:ExpressionFactoryReturn the map entry of the given value.- Specified by:
mapEntryin interfaceExpressionFactory
-
mapKey
Description copied from interface:ExpressionFactoryReturn the map key of the given value- Specified by:
mapKeyin interfaceExpressionFactory
-
getKey
Description copied from interface:ExpressionFactoryPath navigation thru map key- Specified by:
getKeyin interfaceExpressionFactory
-
getObjectId
Description copied from interface:ExpressionFactoryReturn the object id of the given value.- Specified by:
getObjectIdin interfaceExpressionFactory
-
generalCaseExpression
Description copied from interface:ExpressionFactoryReturn a general case expression- Specified by:
generalCaseExpressionin interfaceExpressionFactory
-
simpleCaseExpression
Description copied from interface:ExpressionFactoryReturn a simple case expression- Specified by:
simpleCaseExpressionin interfaceExpressionFactory
-
whenCondition
Description copied from interface:ExpressionFactoryReturn a when condidional clause- Specified by:
whenConditionin interfaceExpressionFactory
-
whenScalar
Description copied from interface:ExpressionFactoryReturn a when scalar_expression clause- Specified by:
whenScalarin interfaceExpressionFactory
-
coalesceExpression
Description copied from interface:ExpressionFactoryReturn a coalesce expression- Specified by:
coalesceExpressionin interfaceExpressionFactory
-
nullIfExpression
Description copied from interface:ExpressionFactoryReturn a nullif expression- Specified by:
nullIfExpressionin interfaceExpressionFactory
-
newFunction
Description copied from interface:ExpressionFactoryReturn a value representing the given datastore function with the given arguments.- Specified by:
newFunctionin interfaceExpressionFactory
-
isVerticalType
Description copied from interface:ExpressionFactoryReturn true if the Value is a Type expression and the Type uses joined table strategy.- Specified by:
isVerticalTypein interfaceExpressionFactory
-