Package org.apache.cayenne.exp
Class FunctionExpressionFactory
- java.lang.Object
-
- org.apache.cayenne.exp.FunctionExpressionFactory
-
public class FunctionExpressionFactory extends Object
Collection of factory methods to create function call expressions.- Since:
- 4.0
-
-
Constructor Summary
Constructors Constructor Description FunctionExpressionFactory()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ExpressionabsExp(String path)static ExpressionabsExp(Expression exp)static ExpressionavgExp(Expression exp)static ExpressionconcatExp(String... paths)Factory method for expression to call CONCAT(string1, string2, ...) functionstatic ExpressionconcatExp(Expression... expressions)Factory method for expression to call CONCAT(string1, string2, ...) functionstatic ExpressioncountDistinctExp(Expression exp)static ExpressioncountExp()static ExpressioncountExp(Expression exp)static ExpressioncurrentDate()static ExpressioncurrentTime()static ExpressioncurrentTimestamp()static ExpressiondayOfMonthExp(String path)static ExpressiondayOfMonthExp(Expression exp)static ExpressiondayOfWeekExp(String path)static ExpressiondayOfWeekExp(Expression exp)static ExpressiondayOfYearExp(String path)static ExpressiondayOfYearExp(Expression exp)static ExpressionhourExp(String path)static ExpressionhourExp(Expression exp)static ExpressionlengthExp(String path)static ExpressionlengthExp(Expression exp)static ExpressionlocateExp(String substring, String path)Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.static ExpressionlocateExp(String substring, Expression exp)Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.static ExpressionlocateExp(Expression substring, Expression exp)Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.static ExpressionlowerExp(String path)static ExpressionlowerExp(Expression exp)static ExpressionmaxExp(Expression exp)static ExpressionminExp(Expression exp)static ExpressionminuteExp(String path)static ExpressionminuteExp(Expression exp)static ExpressionmodExp(String path, Number number)static ExpressionmodExp(Expression exp, Number number)static ExpressionmodExp(Expression exp, Expression number)static ExpressionmonthExp(String path)static ExpressionmonthExp(Expression exp)static ExpressionsecondExp(String path)static ExpressionsecondExp(Expression exp)static ExpressionsqrtExp(String path)static ExpressionsqrtExp(Expression exp)static ExpressionsubstringExp(String path, int offset, int length)Call SUBSTRING(string, offset, length) functionstatic ExpressionsubstringExp(Expression exp, int offset, int length)Call SUBSTRING(string, offset, length) functionstatic ExpressionsubstringExp(Expression exp, Expression offset, Expression length)Call SUBSTRING(string, offset, length) functionstatic ExpressionsumExp(Expression exp)static ExpressiontrimExp(String path)static ExpressiontrimExp(Expression exp)static ExpressionupperExp(String path)static ExpressionupperExp(Expression exp)static ExpressionweekExp(String path)static ExpressionweekExp(Expression exp)static ExpressionyearExp(String path)static ExpressionyearExp(Expression exp)
-
-
-
Method Detail
-
substringExp
public static Expression substringExp(Expression exp, int offset, int length)
Call SUBSTRING(string, offset, length) function- Parameters:
exp- expression that must evaluate to stringoffset- start offset of substringlength- length of substring- Returns:
- SUBSTRING() call expression
-
substringExp
public static Expression substringExp(String path, int offset, int length)
Call SUBSTRING(string, offset, length) function- Parameters:
path- Object path valueoffset- start offset of substringlength- length of substring- Returns:
- SUBSTRING() call expression
-
substringExp
public static Expression substringExp(Expression exp, Expression offset, Expression length)
Call SUBSTRING(string, offset, length) function- Parameters:
exp- expression that must evaluate to stringoffset- start offset of substring must evaluate to intlength- length of substring must evaluate to int- Returns:
- SUBSTRING() call expression
-
trimExp
public static Expression trimExp(Expression exp)
- Parameters:
exp- string expression to trim- Returns:
- TRIM() call expression
-
trimExp
public static Expression trimExp(String path)
- Parameters:
path- object path value- Returns:
- TRIM() call expression
-
lowerExp
public static Expression lowerExp(Expression exp)
- Parameters:
exp- string expression- Returns:
- LOWER() call expression
-
lowerExp
public static Expression lowerExp(String path)
- Parameters:
path- object path value- Returns:
- LOWER() call expression
-
upperExp
public static Expression upperExp(Expression exp)
- Parameters:
exp- string expression- Returns:
- UPPER() call expression
-
upperExp
public static Expression upperExp(String path)
- Parameters:
path- object path value- Returns:
- UPPER() call expression
-
lengthExp
public static Expression lengthExp(Expression exp)
- Parameters:
exp- string expression- Returns:
- LENGTH() call expression
-
lengthExp
public static Expression lengthExp(String path)
- Parameters:
path- object path value- Returns:
- LENGTH() call expression
-
locateExp
public static Expression locateExp(String substring, Expression exp)
Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.- Parameters:
substring- object path valueexp- string expression- Returns:
- LOCATE() call expression
-
locateExp
public static Expression locateExp(String substring, String path)
Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.- Parameters:
substring- object path valuepath- object path- Returns:
- LOCATE() call expression
-
locateExp
public static Expression locateExp(Expression substring, Expression exp)
Call LOCATE(substring, string) function that return position of substring in string or 0 if it is not found.- Parameters:
substring- string expressionexp- string expression- Returns:
- LOCATE() call expression
-
absExp
public static Expression absExp(Expression exp)
- Parameters:
exp- numeric expression- Returns:
- ABS() call expression
-
absExp
public static Expression absExp(String path)
- Parameters:
path- object path value- Returns:
- ABS() call expression
-
sqrtExp
public static Expression sqrtExp(Expression exp)
- Parameters:
exp- numeric expression- Returns:
- SQRT() call expression
-
sqrtExp
public static Expression sqrtExp(String path)
- Parameters:
path- object path value- Returns:
- SQRT() call expression
-
modExp
public static Expression modExp(Expression exp, Number number)
- Parameters:
exp- numeric expressionnumber- divisor- Returns:
- MOD() call expression
-
modExp
public static Expression modExp(String path, Number number)
- Parameters:
path- object path valuenumber- divisor- Returns:
- MOD() call expression
-
modExp
public static Expression modExp(Expression exp, Expression number)
- Parameters:
exp- object path valuenumber- numeric expression- Returns:
- MOD() call expression
-
concatExp
public static Expression concatExp(Expression... expressions)
Factory method for expression to call CONCAT(string1, string2, ...) function
Can be used like:
Expression concat = concatExp(SomeClass.POPERTY_1.getPath(), SomeClass.PROPERTY_2.getPath());
SQL generation note:
- if DB supports CONCAT function with vararg then it will be used
- if DB supports CONCAT function with two args but also supports concat operator, then operator (eg ||) will be used
- if DB supports only CONCAT function with two args then it will be used what can lead to SQL exception if used with more than two arguments
Currently only known DB with limited concatenation functionality is Openbase.
- Parameters:
expressions- array of expressions- Returns:
- CONCAT() call expression
-
concatExp
public static Expression concatExp(String... paths)
Factory method for expression to call CONCAT(string1, string2, ...) function
Can be used like:
Expression concat = concatExp("property1", "property2");SQL generation note:
- if DB supports CONCAT function with vararg then it will be used
- if DB supports CONCAT function with two args but also supports concat operator, then operator (eg ||) will be used
- if DB supports only CONCAT function with two args then it will be used what can lead to SQL exception if used with more than two arguments
Currently only Openbase DB has limited concatenation functionality.
- Parameters:
paths- array of paths- Returns:
- CONCAT() call expression
-
countExp
public static Expression countExp()
- Returns:
- Expression COUNT(*)
-
countExp
public static Expression countExp(Expression exp)
- Returns:
- Expression COUNT(exp)
-
countDistinctExp
public static Expression countDistinctExp(Expression exp)
- Returns:
- Expression COUNT(DISTINCT(exp))
- Since:
- 4.1
-
minExp
public static Expression minExp(Expression exp)
- Returns:
- Expression MIN(exp)
-
maxExp
public static Expression maxExp(Expression exp)
- Returns:
- Expression MAX(exp)
-
avgExp
public static Expression avgExp(Expression exp)
- Returns:
- Expression AVG(exp)
-
sumExp
public static Expression sumExp(Expression exp)
- Returns:
- SUM(exp) expression
-
currentDate
public static Expression currentDate()
- Returns:
- CURRENT_DATE expression
-
currentTime
public static Expression currentTime()
- Returns:
- CURRENT_TIME expression
-
currentTimestamp
public static Expression currentTimestamp()
- Returns:
- CURRENT_TIMESTAMP expression
-
yearExp
public static Expression yearExp(Expression exp)
- Parameters:
exp- date/timestamp expression- Returns:
- year(exp) function expression
-
yearExp
public static Expression yearExp(String path)
- Parameters:
path- String path- Returns:
- year(path) function expression
-
monthExp
public static Expression monthExp(Expression exp)
- Parameters:
exp- date/timestamp expression- Returns:
- month(exp) function expression
-
monthExp
public static Expression monthExp(String path)
- Parameters:
path- String path- Returns:
- month(path) function expression
-
weekExp
public static Expression weekExp(Expression exp)
- Parameters:
exp- date/timestamp expression- Returns:
- week(exp) function expression
-
weekExp
public static Expression weekExp(String path)
- Parameters:
path- String path- Returns:
- week(path) function expression
-
dayOfYearExp
public static Expression dayOfYearExp(Expression exp)
- Parameters:
exp- date/timestamp expression- Returns:
- dayOfYear(exp) function expression
-
dayOfYearExp
public static Expression dayOfYearExp(String path)
- Parameters:
path- String path- Returns:
- dayOfYear(path) function expression
-
dayOfMonthExp
public static Expression dayOfMonthExp(Expression exp)
- Parameters:
exp- date/timestamp expression- Returns:
- dayOfMonth(exp) function expression, synonym for day()
-
dayOfMonthExp
public static Expression dayOfMonthExp(String path)
- Parameters:
path- String path- Returns:
- dayOfMonth(path) function expression, synonym for day()
-
dayOfWeekExp
public static Expression dayOfWeekExp(Expression exp)
- Parameters:
exp- date/timestamp expression- Returns:
- dayOfWeek(exp) function expression
-
dayOfWeekExp
public static Expression dayOfWeekExp(String path)
- Parameters:
path- String path- Returns:
- dayOfWeek(path) function expression
-
hourExp
public static Expression hourExp(Expression exp)
- Parameters:
exp- date/timestamp expression- Returns:
- hour(exp) function expression
-
hourExp
public static Expression hourExp(String path)
- Parameters:
path- String path- Returns:
- hour(path) function expression
-
minuteExp
public static Expression minuteExp(Expression exp)
- Parameters:
exp- date/timestamp expression- Returns:
- minute(exp) function expression
-
minuteExp
public static Expression minuteExp(String path)
- Parameters:
path- String path- Returns:
- minute(path) function expression
-
secondExp
public static Expression secondExp(Expression exp)
- Parameters:
exp- date/timestamp expression- Returns:
- second(exp) function expression
-
secondExp
public static Expression secondExp(String path)
- Parameters:
path- String path- Returns:
- second(path) function expression
-
-