public class

AnsiTrimEmulationFunction

extends AbstractAnsiTrimEmulationFunction
java.lang.Object
   ↳ org.hibernate.dialect.function.AbstractAnsiTrimEmulationFunction
     ↳ org.hibernate.dialect.function.AnsiTrimEmulationFunction

Class Overview

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.

Summary

Constants
String BOTH_SPACE_TRIM_FROM_TEMPLATE
String BOTH_SPACE_TRIM_TEMPLATE
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.
String LEADING_SPACE_TRIM_TEMPLATE
String LEADING_TRIM_TEMPLATE A template for the series of calls required to trim non-space chars from the beginning of text.
String LTRIM
String REPLACE
String RTRIM
String SPACE_PLACEHOLDER
String TRAILING_SPACE_TRIM_TEMPLATE
String TRAILING_TRIM_TEMPLATE A template for the series of calls required to trim non-space chars from the end of text.
Public Constructors
AnsiTrimEmulationFunction()
Constructs a new AnsiTrimEmulationFunction using LTRIM, RTRIM, and REPLACE respectively.
AnsiTrimEmulationFunction(String ltrimFunctionName, String rtrimFunctionName, String replaceFunctionName)
Constructs a trim() emulation function definition using the specified function calls.
Protected Methods
SQLFunction resolveBothSpaceTrimFromFunction()
Resolve the function definition which should be used to trim both leading and trailing spaces.
SQLFunction resolveBothSpaceTrimFunction()
Resolve the function definition which should be used to trim both leading and trailing spaces.
SQLFunction resolveBothTrimFunction()
Resolve the function definition which should be used to trim the specified character from both the beginning (leading) and end (trailing) of the trim source.
SQLFunction resolveLeadingSpaceTrimFunction()
Resolve the function definition which should be used to trim leading spaces.
SQLFunction resolveLeadingTrimFunction()
Resolve the function definition which should be used to trim the specified character from the beginning (leading) of the trim source.
SQLFunction resolveTrailingSpaceTrimFunction()
Resolve the function definition which should be used to trim trailing spaces.
SQLFunction resolveTrailingTrimFunction()
Resolve the function definition which should be used to trim the specified character from the end (trailing) of the trim source.
[Expand]
Inherited Methods
From class org.hibernate.dialect.function.AbstractAnsiTrimEmulationFunction
From class java.lang.Object
From interface org.hibernate.dialect.function.SQLFunction

Constants

public static final String BOTH_SPACE_TRIM_FROM_TEMPLATE

Constant Value: "ltrim(rtrim(?2))"

public static final String BOTH_SPACE_TRIM_TEMPLATE

Constant Value: "ltrim(rtrim(?1))"

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.

Constant Value: "replace(replace(ltrim(rtrim(replace(replace(?1,' ','${space}$'),?2,' '))),' ',?2),'${space}$',' ')"

public static final String LEADING_SPACE_TRIM_TEMPLATE

Constant Value: "ltrim(?1)"

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:

  • replace all space chars with the text '${space}$'
  • replace all the actual replacement chars with space chars
  • perform left-trimming (that removes any of the space chars we just added which occur at the beginning of the text)
  • replace all space chars with the replacement char
  • replace all the '${space}$' text with space chars
  • Constant Value: "replace(replace(ltrim(replace(replace(?1,' ','${space}$'),?2,' ')),' ',?2),'${space}$',' ')"

    public static final String LTRIM

    Constant Value: "ltrim"

    public static final String REPLACE

    Constant Value: "replace"

    public static final String RTRIM

    Constant Value: "rtrim"

    public static final String SPACE_PLACEHOLDER

    Constant Value: "${space}$"

    public static final String TRAILING_SPACE_TRIM_TEMPLATE

    Constant Value: "rtrim(?1)"

    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.

    Constant Value: "replace(replace(rtrim(replace(replace(?1,' ','${space}$'),?2,' ')),' ',?2),'${space}$',' ')"

    Public Constructors

    public AnsiTrimEmulationFunction ()

    Constructs a new AnsiTrimEmulationFunction using LTRIM, RTRIM, and REPLACE respectively.

    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.

    Protected Methods

    protected SQLFunction resolveBothSpaceTrimFromFunction ()

    Resolve the function definition which should be used to trim both leading and trailing spaces.

    The same as {#link resolveBothSpaceTrimFunction} except that here theFROM is included and will need to be accounted for during render(Type, List, SessionFactoryImplementor) processing.

    Returns
    • The sql function

    protected SQLFunction resolveBothSpaceTrimFunction ()

    Resolve the function definition which should be used to trim both leading and trailing spaces.

    In this form, the imput arguments is missing the FROM keyword.

    Returns
    • The sql function

    protected SQLFunction resolveBothTrimFunction ()

    Resolve the function definition which should be used to trim the specified character from both the beginning (leading) and end (trailing) of the trim source.

    Returns
    • The sql function

    protected SQLFunction resolveLeadingSpaceTrimFunction ()

    Resolve the function definition which should be used to trim leading spaces.

    Returns
    • The sql function

    protected SQLFunction resolveLeadingTrimFunction ()

    Resolve the function definition which should be used to trim the specified character from the beginning (leading) of the trim source.

    Returns
    • The sql function

    protected SQLFunction resolveTrailingSpaceTrimFunction ()

    Resolve the function definition which should be used to trim trailing spaces.

    Returns
    • The sql function

    protected SQLFunction resolveTrailingTrimFunction ()

    Resolve the function definition which should be used to trim the specified character from the end (trailing) of the trim source.

    Returns
    • The sql function