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 and Description
    `FunctionExpressionFactory()`

  - ### Method Summary

    All Methods Static Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `static Expression` | `absExp(Expression exp)`
    `static Expression` | `absExp(String path)`
    `static Expression` | `avgExp(Expression exp)`
    `static Expression` | `concatExp(Expression... expressions)` Factory method for expression to call CONCAT(string1, string2, ...) function
    `static Expression` | `concatExp(String... paths)` Factory method for expression to call CONCAT(string1, string2, ...) function
    `static Expression` | `countDistinctExp(Expression exp)`
    `static Expression` | `countExp()`
    `static Expression` | `countExp(Expression exp)`
    `static Expression` | `currentDate()`
    `static Expression` | `currentTime()`
    `static Expression` | `currentTimestamp()`
    `static Expression` | `dayOfMonthExp(Expression exp)`
    `static Expression` | `dayOfMonthExp(String path)`
    `static Expression` | `dayOfWeekExp(Expression exp)`
    `static Expression` | `dayOfWeekExp(String path)`
    `static Expression` | `dayOfYearExp(Expression exp)`
    `static Expression` | `dayOfYearExp(String path)`
    `static Expression` | `functionCall(String function, Object... args)`
    `static Expression` | `hourExp(Expression exp)`
    `static Expression` | `hourExp(String path)`
    `static Expression` | `lengthExp(Expression exp)`
    `static Expression` | `lengthExp(String path)`
    `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.
    `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.
    `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.
    `static Expression` | `lowerExp(Expression exp)`
    `static Expression` | `lowerExp(String path)`
    `static Expression` | `maxExp(Expression exp)`
    `static Expression` | `minExp(Expression exp)`
    `static Expression` | `minuteExp(Expression exp)`
    `static Expression` | `minuteExp(String path)`
    `static Expression` | `modExp(Expression exp, Expression number)`
    `static Expression` | `modExp(Expression exp, Number number)`
    `static Expression` | `modExp(String path, Number number)`
    `static Expression` | `monthExp(Expression exp)`
    `static Expression` | `monthExp(String path)`
    `static Expression` | `operator(String operator, Object... args)`
    `static Expression` | `secondExp(Expression exp)`
    `static Expression` | `secondExp(String path)`
    `static Expression` | `sqrtExp(Expression exp)`
    `static Expression` | `sqrtExp(String path)`
    `static Expression` | `substringExp(Expression exp, Expression offset, Expression length)` Call SUBSTRING(string, offset, length) function
    `static Expression` | `substringExp(Expression exp, int offset, int length)` Call SUBSTRING(string, offset, length) function
    `static Expression` | `substringExp(String path, int offset, int length)` Call SUBSTRING(string, offset, length) function
    `static Expression` | `sumExp(Expression exp)`
    `static Expression` | `trimExp(Expression exp)`
    `static Expression` | `trimExp(String path)`
    `static Expression` | `upperExp(Expression exp)`
    `static Expression` | `upperExp(String path)`
    `static Expression` | `weekExp(Expression exp)`
    `static Expression` | `weekExp(String path)`
    `static Expression` | `yearExp(Expression exp)`
    `static Expression` | `yearExp(String path)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### FunctionExpressionFactory

          public FunctionExpressionFactory()

  - ### 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 string
        `offset` - start offset of substring
        `length` - 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 value
        `offset` - start offset of substring
        `length` - 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 string
        `offset` - start offset of substring must evaluate to int
        `length` - 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 value
        `exp` - 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 value
        `path` - 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 expression
        `exp` - 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 expression
        `number` - divisor
      Returns:
        MOD() call expression

    - #### modExp

          public static Expression modExp(String path,
                                          Number number)

      Parameters:
        `path` - object path value
        `number` - divisor
      Returns:
        MOD() call expression

    - #### modExp

          public static Expression modExp(Expression exp,
                                          Expression number)

      Parameters:
        `exp` - object path value
        `number` - 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

    - #### functionCall

          public static Expression functionCall(String function,
                                                Object... args)

      Parameters:
        `function` - name to call
        `args` - function arguments
      Returns:
        expression to call "function" with provided arguments
      Since:
        4.2

    - #### operator

          public static Expression operator(String operator,
                                            Object... args)

      Parameters:
        `operator` - to call
        `args` - arguments
      Returns:
        expression to use custom "operator" with provided arguments
      Since:
        4.2

Copyright © 2001–2021 Apache Cayenne. All rights reserved.