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 SummaryConstructors
- 
Method SummaryModifier 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- 
InMemoryExpressionFactorypublic InMemoryExpressionFactory()
 
- 
- 
Method Details- 
matchespublic 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.
- 
matchesRecursive 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.
- 
groupGroup the list of matches into a list of lists.
- 
matchesReturn true if the given group matches the having expression.
- 
projectCreate the projections for the given results.
- 
orderOrder the given list of matches on the given value.
- 
distinctFilter the given list of matches, removing duplicate entries.
- 
emptyExpressionDescription copied from interface:ExpressionFactoryReturn a blank expression; this is used when the filter is empty.- Specified by:
- emptyExpressionin interface- ExpressionFactory
 
- 
asExpressionDescription copied from interface:ExpressionFactoryReturn the given value as an expression.- Specified by:
- asExpressionin interface- ExpressionFactory
 
- 
equalDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- equalin interface- ExpressionFactory
 
- 
notEqualDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- notEqualin interface- ExpressionFactory
 
- 
lessThanDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- lessThanin interface- ExpressionFactory
 
- 
greaterThanDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- greaterThanin interface- ExpressionFactory
 
- 
lessThanEqualDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- lessThanEqualin interface- ExpressionFactory
 
- 
greaterThanEqualDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- greaterThanEqualin interface- ExpressionFactory
 
- 
isEmptyDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- isEmptyin interface- ExpressionFactory
 
- 
isNotEmptyDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- isNotEmptyin interface- ExpressionFactory
 
- 
containsDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- containsin interface- ExpressionFactory
 
- 
containsKeyDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- containsKeyin interface- ExpressionFactory
 
- 
containsValueDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- containsValuein interface- ExpressionFactory
 
- 
getMapValueDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- getMapValuein interface- ExpressionFactory
 
- 
isInstanceDescription copied from interface:ExpressionFactoryReturn whether the first value is an instance of the given class.- Specified by:
- isInstancein interface- ExpressionFactory
 
- 
andDescription copied from interface:ExpressionFactoryReturn the two expressions AND'd together.- Specified by:
- andin interface- ExpressionFactory
 
- 
orDescription copied from interface:ExpressionFactoryReturn the two expressions OR'd together.- Specified by:
- orin interface- ExpressionFactory
 
- 
notDescription copied from interface:ExpressionFactoryReturn the inverse of this expression.- Specified by:
- notin interface- ExpressionFactory
 
- 
bindVariableDescription copied from interface:ExpressionFactoryBind the given variable to the given collection value.- Specified by:
- bindVariablein interface- ExpressionFactory
 
- 
bindKeyVariableDescription copied from interface:ExpressionFactoryBind the given variable to the key set of the given map value.- Specified by:
- bindKeyVariablein interface- ExpressionFactory
 
- 
bindValueVariableDescription copied from interface:ExpressionFactoryBind the given variable to the value set of the given map value.- Specified by:
- bindValueVariablein interface- ExpressionFactory
 
- 
endsWithDescription copied from interface:ExpressionFactoryReturn whether the first string ends with the second.- Specified by:
- endsWithin interface- ExpressionFactory
 
- 
matchesDescription copied from interface:ExpressionFactoryReturn whether the string matches the matching pattern.- Specified by:
- matchesin interface- ExpressionFactory
- Parameters:
- v1- the value to compare
- v2- the pattern against which to compare
- single- the token that signifies a single-character match
- multi- the token that signifies a multi-character match
- esc- the escape token that escapes the matching tokens
 
- 
notMatchesDescription copied from interface:ExpressionFactoryReturn whether the string does not match the given pattern.- Specified by:
- notMatchesin interface- ExpressionFactory
- Parameters:
- v1- the value to compare
- v2- the pattern against which to compare
- single- the token that signifies a single-character match
- multi- the token that signifies a multi-character match
- esc- the escape token that escapes the matching tokens
 
- 
startsWithDescription copied from interface:ExpressionFactoryReturn whether the first string starts with the second.- Specified by:
- startsWithin interface- ExpressionFactory
 
- 
newSubqueryDescription 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 interface- ExpressionFactory
- Parameters:
- candidate- the candidate class of the subquery
- subs- whether the query includes subclasses
- alias- the alias given to the query candidate class
 
- 
newPathDescription 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 interface- ExpressionFactory
 
- 
newPathDescription 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 interface- ExpressionFactory
 
- 
newLiteralDescription copied from interface:ExpressionFactoryReturn a value representing the given constant, which will be aNumber,String, orBooleaninstance.- Specified by:
- newLiteralin interface- ExpressionFactory
 
- 
newTypeLiteralDescription copied from interface:ExpressionFactoryReturn a value representing the given constant, which will be aNumber,String, orBooleaninstance.- Specified by:
- newTypeLiteralin interface- ExpressionFactory
 
- 
getThisDescription copied from interface:ExpressionFactoryReturn a value representingthis.- Specified by:
- getThisin interface- ExpressionFactory
 
- 
getNullDescription copied from interface:ExpressionFactoryReturn a value representing null.- Specified by:
- getNullin interface- ExpressionFactory
 
- 
getCurrentDateDescription copied from interface:ExpressionFactoryReturn a value representing the current date.- Specified by:
- getCurrentDatein interface- ExpressionFactory
 
- 
getCurrentTimeDescription copied from interface:ExpressionFactoryReturn a value representing the current time.- Specified by:
- getCurrentTimein interface- ExpressionFactory
 
- 
getCurrentTimestampDescription copied from interface:ExpressionFactoryReturn a value representing the current timestamp.- Specified by:
- getCurrentTimestampin interface- ExpressionFactory
 
- 
newParameterDescription 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 interface- ExpressionFactory
 
- 
newCollectionValuedParameterDescription copied from interface:ExpressionFactoryReturn a value representing a collection-valued parameter. The type may beObjectif the parameter is not declared.- Specified by:
- newCollectionValuedParameterin interface- ExpressionFactory
 
- 
newExtensionDescription copied from interface:ExpressionFactoryReturn the value of the given extension.- Specified by:
- newExtensionin interface- ExpressionFactory
 
- 
newAggregateDescription copied from interface:ExpressionFactoryReturn the value of the given function.- Specified by:
- newAggregatein interface- ExpressionFactory
 
- 
newArgumentListDescription 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 interface- ExpressionFactory
 
- 
newArgumentListDescription 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 interface- ExpressionFactory
 
- 
newUnboundVariableDescription 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 interface- ExpressionFactory
 
- 
newBoundVariableDescription 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 interface- ExpressionFactory
 
- 
castDescription copied from interface:ExpressionFactoryCast the value to the given class.- Specified by:
- castin interface- ExpressionFactory
 
- 
addDescription copied from interface:ExpressionFactoryReturn a value representing the two values added together.- Specified by:
- addin interface- ExpressionFactory
 
- 
subtractDescription copied from interface:ExpressionFactoryReturn a value representing the second value subtracted from the first.- Specified by:
- subtractin interface- ExpressionFactory
 
- 
multiplyDescription copied from interface:ExpressionFactoryReturn a value representing the two values multiplied together.- Specified by:
- multiplyin interface- ExpressionFactory
 
- 
divideDescription copied from interface:ExpressionFactoryReturn a value representing the first value divided by the first one.- Specified by:
- dividein interface- ExpressionFactory
 
- 
modDescription copied from interface:ExpressionFactoryReturn a value representing the first value mod'd by the second one.- Specified by:
- modin interface- ExpressionFactory
 
- 
absDescription copied from interface:ExpressionFactoryReturn a value representing the absolute value of the given one.- Specified by:
- absin interface- ExpressionFactory
 
- 
indexOfDescription 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 interface- ExpressionFactory
 
- 
concatDescription copied from interface:ExpressionFactoryReturn a value representing the concatenation of the given target with the given args.- Specified by:
- concatin interface- ExpressionFactory
 
- 
stringLengthDescription copied from interface:ExpressionFactoryReturns the number of characters in the String value.- Specified by:
- stringLengthin interface- ExpressionFactory
 
- 
trimDescription copied from interface:ExpressionFactoryTrims the specified specified trimChar from the specified value.- Specified by:
- trimin interface- ExpressionFactory
- Parameters:
- str- the value from which to trim
- trimChar- the characters to trim off
- where- which side of the String to trim: null indicates both sides, true indicates leading, and false indicates trailing
 
- 
sqrtDescription copied from interface:ExpressionFactoryReturn the square root of the given value.- Specified by:
- sqrtin interface- ExpressionFactory
 
- 
substringDescription 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 interface- ExpressionFactory
 
- 
toUpperCaseDescription copied from interface:ExpressionFactoryReturn the upper case of the given value.- Specified by:
- toUpperCasein interface- ExpressionFactory
 
- 
toLowerCaseDescription copied from interface:ExpressionFactoryReturn the upper case of the given value.- Specified by:
- toLowerCasein interface- ExpressionFactory
 
- 
avgDescription copied from interface:ExpressionFactoryReturn the average of the given value for all matches.- Specified by:
- avgin interface- ExpressionFactory
 
- 
countDescription copied from interface:ExpressionFactoryReturn the count of the given value for all matches.- Specified by:
- countin interface- ExpressionFactory
 
- 
distinctDescription copied from interface:ExpressionFactoryReturn distinct values of the given value. This is typically used within aggregates, for example: max(distinct(path))- Specified by:
- distinctin interface- ExpressionFactory
 
- 
maxDescription copied from interface:ExpressionFactoryReturn the max of the given value for all matches.- Specified by:
- maxin interface- ExpressionFactory
 
- 
minDescription copied from interface:ExpressionFactoryReturn the max of the given value for all matches.- Specified by:
- minin interface- ExpressionFactory
 
- 
sumDescription copied from interface:ExpressionFactoryReturn the max of the given value for all matches.- Specified by:
- sumin interface- ExpressionFactory
 
- 
anyDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- anyin interface- ExpressionFactory
 
- 
allDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- allin interface- ExpressionFactory
 
- 
sizeDescription copied from interface:ExpressionFactoryReturn an expression representing the given condition.- Specified by:
- sizein interface- ExpressionFactory
 
- 
indexDescription copied from interface:ExpressionFactoryReturn an index/position of the given value within a collection/map.- Specified by:
- indexin interface- ExpressionFactory
 
- 
typeDescription copied from interface:ExpressionFactoryReturn the type/class of the given value.- Specified by:
- typein interface- ExpressionFactory
 
- 
mapEntryDescription copied from interface:ExpressionFactoryReturn the map entry of the given value.- Specified by:
- mapEntryin interface- ExpressionFactory
 
- 
mapKeyDescription copied from interface:ExpressionFactoryReturn the map key of the given value- Specified by:
- mapKeyin interface- ExpressionFactory
 
- 
getKeyDescription copied from interface:ExpressionFactoryPath navigation thru map key- Specified by:
- getKeyin interface- ExpressionFactory
 
- 
getObjectIdDescription copied from interface:ExpressionFactoryReturn the object id of the given value.- Specified by:
- getObjectIdin interface- ExpressionFactory
 
- 
generalCaseExpressionDescription copied from interface:ExpressionFactoryReturn a general case expression- Specified by:
- generalCaseExpressionin interface- ExpressionFactory
 
- 
simpleCaseExpressionDescription copied from interface:ExpressionFactoryReturn a simple case expression- Specified by:
- simpleCaseExpressionin interface- ExpressionFactory
 
- 
whenConditionDescription copied from interface:ExpressionFactoryReturn a when condidional clause- Specified by:
- whenConditionin interface- ExpressionFactory
 
- 
whenScalarDescription copied from interface:ExpressionFactoryReturn a when scalar_expression clause- Specified by:
- whenScalarin interface- ExpressionFactory
 
- 
coalesceExpressionDescription copied from interface:ExpressionFactoryReturn a coalesce expression- Specified by:
- coalesceExpressionin interface- ExpressionFactory
 
- 
nullIfExpressionDescription copied from interface:ExpressionFactoryReturn a nullif expression- Specified by:
- nullIfExpressionin interface- ExpressionFactory
 
- 
newFunctionDescription copied from interface:ExpressionFactoryReturn a value representing the given datastore function with the given arguments.- Specified by:
- newFunctionin interface- ExpressionFactory
 
- 
isVerticalTypeDescription copied from interface:ExpressionFactoryReturn true if the Value is a Type expression and the Type uses joined table strategy.- Specified by:
- isVerticalTypein interface- ExpressionFactory
 
 
-