org.apache.openjpa.kernel.exps
Interface ExpressionFactory

All Known Implementing Classes:
InMemoryExpressionFactory, JDBCExpressionFactory

public interface ExpressionFactory

The ExpressionFactory must be implemented by a particular runtime to form Expressions in its native query language.

Author:
Abe White

Method Summary
 Value abs(Value num)
          Return a value representing the absolute value of the given one.
 Value add(Value num1, Value num2)
          Return a value representing the two values added together.
 Value all(Value target)
          Return an expression representing the given condition.
 Expression and(Expression exp1, Expression exp2)
          Return the two expressions AND'd together.
 Value any(Value target)
          Return an expression representing the given condition.
 Expression asExpression(Value bool)
          Return the given value as an expression.
 Value avg(Value num)
          Return the average of the given value for all matches.
 Expression bindKeyVariable(Value var, Value map)
          Bind the given variable to the key set of the given map value.
 Expression bindValueVariable(Value var, Value map)
          Bind the given variable to the value set of the given map value.
 Expression bindVariable(Value var, Value coll)
          Bind the given variable to the given collection value.
 Value cast(Value obj, Class cls)
          Cast the value to the given class.
 Value concat(Value str, Value args)
          Return a value representing the concatenation of the given target with the given args.
 Expression contains(Value coll, Value arg)
          Return an expression representing the given condition.
 Expression containsKey(Value map, Value arg)
          Return an expression representing the given condition.
 Expression containsValue(Value map, Value arg)
          Return an expression representing the given condition.
 Value count(Value obj)
          Return the count of the given value for all matches.
 Value distinct(Value obj)
          Return distinct values of the given value.
 Value divide(Value num1, Value num2)
          Return a value representing the first value divided by the first one.
 Expression emptyExpression()
          Return a blank expression; this is used when the filter is empty.
 Expression endsWith(Value str1, Value str2)
          Return whether the first string ends with the second.
 Expression equal(Value v1, Value v2)
          Return an expression representing the given condition.
 Value getCurrentDate()
          Return a value representing the current date.
 Value getCurrentTime()
          Return a value representing the current time.
 Value getCurrentTimestamp()
          Return a value representing the current timestamp.
 Value getMapValue(Value map, Value arg)
          Return an expression representing the given condition.
 Value getNull()
          Return a value representing null.
 Value getObjectId(Value val)
          Return the object id of the given value.
 Value getThis()
          Return a value representing this.
 Expression greaterThan(Value v1, Value v2)
          Return an expression representing the given condition.
 Expression greaterThanEqual(Value v1, Value v2)
          Return an expression representing the given condition.
 Value indexOf(Value str, Value args)
          Return a value representing the String.indexOf(int) function on the given target with the given args.
 Expression isEmpty(Value target)
          Return an expression representing the given condition.
 Expression isInstance(Value obj, Class c)
          Return whether the first value is an instance of the given class.
 Expression isNotEmpty(Value target)
          Return an expression representing the given condition.
 Expression lessThan(Value v1, Value v2)
          Return an expression representing the given condition.
 Expression lessThanEqual(Value v1, Value v2)
          Return an expression representing the given condition.
 Expression matches(Value str, Value regexp, String single, String multi, String escape)
          Return whether the string matches the matching pattern.
 Value max(Value num)
          Return the max of the given value for all matches.
 Value min(Value num)
          Return the max of the given value for all matches.
 Value mod(Value num1, Value num2)
          Return a value representing the first value mod'd by the second one.
 Value multiply(Value num1, Value num2)
          Return a value representing the two values multiplied together.
 Value newAggregate(AggregateListener listener, Value args)
          Return the value of the given function.
 Arguments newArgumentList(Value arg1, Value arg2)
          Return a function argument list consisting of the given values, either of which may itself be an argument list.
 Value newBoundVariable(String name, Class type)
          This method will be called only once per variable bound in a contains clause, and the returned value will be reused for any further instances of the variable in subexpression of the filter string.
 Value newExtension(FilterListener listener, Value target, Value args)
          Return the value of the given extension.
 Literal newLiteral(Object val, int parseType)
          Return a value representing the given constant, which will be a Number, String, or Boolean instance.
 Parameter newParameter(String name, Class type)
          Return a value representing a parameter for the given value.
 Path newPath()
          Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the candidate class.
Example: parent.address.city
 Path newPath(Value val)
          Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the given value.
Example: var.address.city
 Subquery newSubquery(ClassMetaData candidate, boolean subs, String alias)
          Return a subquery.
 Value newUnboundVariable(String name, Class type)
          Return an unbound variable.
 Expression not(Expression exp)
          Return the inverse of this expression.
 Expression notEqual(Value v1, Value v2)
          Return an expression representing the given condition.
 Expression notMatches(Value str, Value regexp, String single, String multi, String escape)
          Return whether the string does not match the given pattern.
 Expression or(Expression exp1, Expression exp2)
          Return the two expressions OR'd together.
 Value size(Value target)
          Return an expression representing the given condition.
 Value sqrt(Value num)
          Return the square root of the given value.
 Expression startsWith(Value str1, Value str2)
          Return whether the first string starts with the second.
 Value stringLength(Value str)
          Returns the number of characters in the String value.
 Value substring(Value str, Value args)
          Return a value representing the String.substring(int) function on the given target with the given args.
 Value subtract(Value num1, Value num2)
          Return a value representing the second value subtracted from the first.
 Value sum(Value num)
          Return the max of the given value for all matches.
 Value toLowerCase(Value str)
          Return the upper case of the given value.
 Value toUpperCase(Value str)
          Return the upper case of the given value.
 Value trim(Value str, Value trimChar, Boolean where)
          Trims the specified specified trimChar from the specified value.
 

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 compare
regexp - the pattern against which to compare
single - the token that signifies a single-character match
multi - the token that signifies a multi-character match
escape - 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 compare
regexp - the pattern against which to compare
single - the token that signifies a single-character match
multi - the token that signifies a multi-character match
escape - the escape token that escapes the matching tokens

startsWith

Expression startsWith(Value str1,
                      Value str2)
Return whether the first string starts with the second.


stringLength

Value stringLength(Value str)
Returns the number of characters in the String value.


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 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

newSubquery

Subquery newSubquery(ClassMetaData candidate,
                     boolean subs,
                     String alias)
Return a subquery. Paths for the candidates of the subquery are created with newPath(Value), passing in the subquery as the value.

Parameters:
candidate - the candidate class of the subquery
subs - whether the query includes subclasses
alias - the alias given to the query candidate class

newPath

Path newPath()
Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the candidate class.
Example: parent.address.city


newPath

Path newPath(Value val)
Return a value representing a path which will consist of a chain of 1 or more field names starting in the namespace of the given value.
Example: var.address.city


newLiteral

Literal newLiteral(Object val,
                   int parseType)
Return a value representing the given constant, which will be a Number, String, or Boolean instance.


getThis

Value getThis()
Return a value representing this.


getNull

Value getNull()
Return a value representing null.


getCurrentDate

Value getCurrentDate()
Return a value representing the current date.


getCurrentTime

Value getCurrentTime()
Return a value representing the current time.


getCurrentTimestamp

Value getCurrentTimestamp()
Return a value representing the current timestamp.


newParameter

Parameter newParameter(String name,
                       Class type)
Return a value representing a parameter for the given value. The type may be Object if the parameter is not declared.


newExtension

Value newExtension(FilterListener listener,
                   Value target,
                   Value args)
Return the value of the given extension.


newAggregate

Value newAggregate(AggregateListener listener,
                   Value args)
Return the value of the given function.


newArgumentList

Arguments newArgumentList(Value arg1,
                          Value arg2)
Return a function argument list consisting of the given values, either of which may itself be an argument list.


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 be Object if the variable is not declared.


newBoundVariable

Value newBoundVariable(String name,
                       Class type)
This method will be called only once per variable bound in a contains clause, and the returned value will be reused for any further instances of the variable in subexpression of the filter string. The type may be Object if the variable is not declared.


cast

Value cast(Value obj,
           Class cls)
Cast the value to the given class.


add

Value add(Value num1,
          Value num2)
Return a value representing the two values added together.


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.


abs

Value abs(Value num)
Return a value representing the absolute value of the given one.


indexOf

Value indexOf(Value str,
              Value args)
Return a value representing the String.indexOf(int) function on the given target with the given args.


concat

Value concat(Value str,
             Value args)
Return a value representing the concatenation of the given target with the given args.


sqrt

Value sqrt(Value num)
Return the square root of the given value.


substring

Value substring(Value str,
                Value args)
Return a value representing the String.substring(int) function on the given target with the given args. As with String.substring(int), the start index is zero-based, and the second argument is the end index.


toUpperCase

Value toUpperCase(Value str)
Return the upper case of the given value.


toLowerCase

Value toLowerCase(Value str)
Return the upper case of the given value.


avg

Value avg(Value num)
Return the average of the given value for all matches.


count

Value count(Value obj)
Return the count of the given value for all matches.


max

Value max(Value num)
Return the max of the given value for all matches.


min

Value min(Value num)
Return the max of the given value for all matches.


sum

Value sum(Value num)
Return the max of the given value for all matches.


any

Value any(Value target)
Return an expression representing the given condition.

Since:
0.4.0.0

all

Value all(Value target)
Return an expression representing the given condition.

Since:
0.4.0.0

size

Value size(Value target)
Return an expression representing the given condition.

Since:
0.4.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

getObjectId

Value getObjectId(Value val)
Return the object id of the given value.



Copyright © 2006-2008 Apache Software Foundation. All Rights Reserved.