Class AnsiTrimEmulationFunction

  • All Implemented Interfaces:
    SQLFunction

    public class AnsiTrimEmulationFunction
    extends AbstractAnsiTrimEmulationFunction
    A SQLFunction implementation that emulates the ANSI SQL trim function on dialects which do not support the full definition. However, this function definition does assume the availability of ltrim, rtrim, and replace functions which it uses in various combinations to emulate the desired ANSI trim() functionality.
    • Field Detail

      • SPACE_PLACEHOLDER

        public static final String SPACE_PLACEHOLDER
        The placeholder used to represent whitespace
        See Also:
        Constant Field Values
      • LEADING_SPACE_TRIM_TEMPLATE

        public static final String LEADING_SPACE_TRIM_TEMPLATE
        The SQLFunctionTemplate pattern for the trimming leading spaces
        See Also:
        Constant Field Values
      • TRAILING_SPACE_TRIM_TEMPLATE

        public static final String TRAILING_SPACE_TRIM_TEMPLATE
        The SQLFunctionTemplate pattern for the trimming trailing spaces
        See Also:
        Constant Field Values
      • BOTH_SPACE_TRIM_TEMPLATE

        public static final String BOTH_SPACE_TRIM_TEMPLATE
        The SQLFunctionTemplate pattern for the trimming both leading and trailing spaces
        See Also:
        Constant Field Values
      • BOTH_SPACE_TRIM_FROM_TEMPLATE

        public static final String BOTH_SPACE_TRIM_FROM_TEMPLATE
        The SQLFunctionTemplate pattern for the trimming both leading and trailing spaces, with the optional FROM keyword. Different because we need to skip the FROM keyword in the SQLFunctionTemplate processing
        See Also:
        Constant Field Values
      • LEADING_TRIM_TEMPLATE

        public static final String LEADING_TRIM_TEMPLATE
        A template for the series of calls required to trim non-space chars from the beginning of text.

        NOTE : essentially we:

        1. replace all space chars with the text '${space}$'
        2. replace all the actual replacement chars with space chars
        3. perform left-trimming (that removes any of the space chars we just added which occur at the beginning of the text)
        4. replace all space chars with the replacement char
        5. replace all the '${space}$' text with space chars
        See Also:
        Constant Field Values
      • TRAILING_TRIM_TEMPLATE

        public static final String TRAILING_TRIM_TEMPLATE
        A template for the series of calls required to trim non-space chars from the end of text.

        NOTE: essentially the same series of calls as outlined in LEADING_TRIM_TEMPLATE except that here, instead of left-trimming the added spaces, we right-trim them to remove them from the end of the text.

        See Also:
        Constant Field Values
      • BOTH_TRIM_TEMPLATE

        public static final String BOTH_TRIM_TEMPLATE
        A template for the series of calls required to trim non-space chars from both the beginning and the end of text.

        NOTE: again, we have a series of calls that is essentially the same as outlined in LEADING_TRIM_TEMPLATE except that here we perform both left (leading) and right (trailing) trimming.

        See Also:
        Constant Field Values
    • Constructor Detail

      • AnsiTrimEmulationFunction

        public AnsiTrimEmulationFunction​(String ltrimFunctionName,
                                         String rtrimFunctionName,
                                         String replaceFunctionName)
        Constructs a trim() emulation function definition using the specified function calls.
        Parameters:
        ltrimFunctionName - The left trim function to use.
        rtrimFunctionName - The right trim function to use.
        replaceFunctionName - The replace function to use.