Package org.apache.openjpa.kernel.exps
Interface ExpressionFactory
- 
- All Known Implementing Classes:
 InMemoryExpressionFactory,JDBCExpressionFactory
public interface ExpressionFactoryThe ExpressionFactory must be implemented by a particular runtime to formExpressions in its native query language.- Author:
 - Abe White
 
 
- 
- 
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Valueabs(Value num)Return a value representing the absolute value of the given one.Valueadd(Value num1, Value num2)Return a value representing the two values added together.Valueall(Value target)Return an expression representing the given condition.Expressionand(Expression exp1, Expression exp2)Return the two expressions AND'd together.Valueany(Value target)Return an expression representing the given condition.ExpressionasExpression(Value bool)Return the given value as an expression.Valueavg(Value num)Return the average of the given value for all matches.ExpressionbindKeyVariable(Value var, Value map)Bind the given variable to the key set of the given map value.ExpressionbindValueVariable(Value var, Value map)Bind the given variable to the value set of the given map value.ExpressionbindVariable(Value var, Value coll)Bind the given variable to the given collection value.Valuecast(Value obj, Class cls)Cast the value to the given class.Valueceiling(Value num)Returns a value representing the ceiling value of the given one.ValuecoalesceExpression(Value[] val)Return a coalesce expressionValueconcat(Value str, Value args)Return a value representing the concatenation of the given target with the given args.Expressioncontains(Value coll, Value arg)Return an expression representing the given condition.ExpressioncontainsKey(Value map, Value arg)Return an expression representing the given condition.ExpressioncontainsValue(Value map, Value arg)Return an expression representing the given condition.Valuecount(Value obj)Return the count of the given value for all matches.Valuedistinct(Value obj)Return distinct values of the given value.Valuedivide(Value num1, Value num2)Return a value representing the first value divided by the first one.ExpressionemptyExpression()Return a blank expression; this is used when the filter is empty.ExpressionendsWith(Value str1, Value str2)Return whether the first string ends with the second.Expressionequal(Value v1, Value v2)Return an expression representing the given condition.Valueexp(Value num)Returns a value representing the Euler's e constant powered to the given value.Valuefloor(Value num)Returns a value representing the floor of the given value.ValuegeneralCaseExpression(Expression[] exp, Value val)Return a general case expression<T extends Date>
ValuegetCurrentDate(Class<T> dateType)Return a value representing the current date.<T extends Temporal>
ValuegetCurrentLocalDateTime(Class<T> temporalType)Return a value representing the current local temporal.<T extends Date>
ValuegetCurrentTime(Class<T> timeType)Return a value representing the current time.<T extends Date>
ValuegetCurrentTimestamp(Class<T> timestampType)Return a value representing the current timestamp.ValuegetDateTimeField(DateTimeExtractField field, Value value)Returns the integer or double value of the required ChronoField from the temporal valueValuegetDateTimePart(DateTimeExtractPart part, Value value)Return the Date or time part of the given temporal valueValuegetKey(Value val)Path navigation thru map keyValuegetMapValue(Value map, Value arg)Return an expression representing the given condition.ValuegetNull()Return a value representing null.ValuegetObjectId(Value val)Return the object id of the given value.ValuegetThis()Return a value representingthis.ExpressiongreaterThan(Value v1, Value v2)Return an expression representing the given condition.ExpressiongreaterThanEqual(Value v1, Value v2)Return an expression representing the given condition.Valueindex(Value target)Return an index/position of the given value within a collection/map.ValueindexOf(Value str, Value args)Return a value representing the indexOf (LOCATE in JPQL) function on the given target with the given args.ExpressionisEmpty(Value target)Return an expression representing the given condition.ExpressionisInstance(Value obj, Class c)Return whether the first value is an instance of the given class.ExpressionisNotEmpty(Value target)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.ExpressionlessThan(Value v1, Value v2)Return an expression representing the given condition.ExpressionlessThanEqual(Value v1, Value v2)Return an expression representing the given condition.Valueln(Value num)Returns the natural logarithm of the given valueValuemapEntry(Value key, Value val)Return the map entry of the given value.ValuemapKey(Value key, Value val)Return the map key of the given valueExpressionmatches(Value str, Value regexp, String single, String multi, String escape)Return whether the string matches the matching pattern.Valuemax(Value num)Return the max of the given value for all matches.Valuemin(Value num)Return the max of the given value for all matches.Valuemod(Value num1, Value num2)Return a value representing the first value mod'd by the second one.Valuemultiply(Value num1, Value num2)Return a value representing the two values multiplied together.ValuenewAggregate(AggregateListener listener, Value args)Return the value of the given function.ArgumentsnewArgumentList(Value... values)Return a function argument list consisting of the given values, any of which may itself be an argument list.ArgumentsnewArgumentList(Value arg1, Value arg2)Return a function argument list consisting of the given values, either of which may itself be an argument list.ValuenewBoundVariable(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.ParameternewCollectionValuedParameter(Object name, Class type)Return a value representing a collection-valued parameter.ValuenewExtension(FilterListener listener, Value target, Value args)Return the value of the given extension.ValuenewFunction(String functionName, Class<?> resultType, Value... args)Return a value representing the given datastore function with the given arguments.LiteralnewLiteral(Object val, int parseType)ParameternewParameter(Object name, Class type)Return a value representing a parameter for the given value.PathnewPath()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.cityPathnewPath(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.citySubquerynewSubquery(ClassMetaData candidate, boolean subs, String alias)Return a subquery.LiteralnewTypeLiteral(Object val, int parseType)ValuenewUnboundVariable(String name, Class type)Return an unbound variable.Expressionnot(Expression exp)Return the inverse of this expression.ExpressionnotEqual(Value v1, Value v2)Return an expression representing the given condition.ExpressionnotMatches(Value str, Value regexp, String single, String multi, String escape)Return whether the string does not match the given pattern.ValuenullIfExpression(Value val1, Value val2)Return a nullif expressionExpressionor(Expression exp1, Expression exp2)Return the two expressions OR'd together.Valuepower(Value base, Value exponent)Returns a value representing base powered by the exponentValueround(Value num, Value precision)Valuesign(Value num)Returns the sign of the given value as a number (-1 for negative, 0 for zeroes and 1 for positive)ValuesimpleCaseExpression(Value caseOperand, Expression[] exp, Value val)Return a simple case expressionValuesize(Value target)Return an expression representing the given condition.Valuesqrt(Value num)Return the square root of the given value.ExpressionstartsWith(Value str1, Value str2)Return whether the first string starts with the second.ValuestringLength(Value str)Returns the number of characters in the String value.Valuesubstring(Value str, Value args)Return a value representing the substring function on the given target with the given args.Valuesubtract(Value num1, Value num2)Return a value representing the second value subtracted from the first.Valuesum(Value num)Return the max of the given value for all matches.ValuetoLowerCase(Value str)Return the upper case of the given value.ValuetoUpperCase(Value str)Return the upper case of the given value.Valuetrim(Value str, Value trimChar, Boolean where)Trims the specified specified trimChar from the specified value.Valuetype(Value target)Return the type/class of the given value.ExpressionwhenCondition(Expression exp, Value val)Return a when condidional clauseExpressionwhenScalar(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, 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, String single, String multi, 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, String single, String multi, 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, 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, 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 
- 
getThis
Value getThis()
Return a value representingthis. 
- 
getNull
Value getNull()
Return a value representing null. 
- 
getCurrentDate
<T extends Date> Value getCurrentDate(Class<T> dateType)
Return a value representing the current date. 
- 
getCurrentTime
<T extends Date> Value getCurrentTime(Class<T> timeType)
Return a value representing the current time. 
- 
getCurrentTimestamp
<T extends Date> Value getCurrentTimestamp(Class<T> timestampType)
Return a value representing the current timestamp. 
- 
getCurrentLocalDateTime
<T extends Temporal> Value getCurrentLocalDateTime(Class<T> temporalType)
Return a value representing the current local temporal. 
- 
getDateTimeField
Value getDateTimeField(DateTimeExtractField field, Value value)
Returns the integer or double value of the required ChronoField from the temporal value 
- 
getDateTimePart
Value getDateTimePart(DateTimeExtractPart part, Value value)
Return the Date or time part of the given temporal value 
- 
newParameter
Parameter newParameter(Object name, Class type)
Return a value representing a parameter for the given value. The type may beObjectif the parameter is not declared. 
- 
newCollectionValuedParameter
Parameter newCollectionValuedParameter(Object name, Class type)
Return a value representing a collection-valued parameter. The type may beObjectif 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(String name, Class type)
Return 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. 
- 
newBoundVariable
Value 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. The type may beObjectif 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. 
- 
exp
Value exp(Value num)
Returns a value representing the Euler's e constant powered to the given value. 
- 
sign
Value sign(Value num)
Returns the sign of the given value as a number (-1 for negative, 0 for zeroes and 1 for positive) 
- 
power
Value power(Value base, Value exponent)
Returns a value representing base powered by the exponent 
- 
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 
- 
newFunction
Value newFunction(String functionName, 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. 
 - 
 
 -