EclipseLink 2.4.1, build 'v20121003-ad44345' API Reference

org.eclipse.persistence.jpa.jpql
Class ExpressionTools

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.ExpressionTools

public final class ExpressionTools
extends java.lang.Object

A utility class containing various methods related to the Hermes parser.

Provisional API: This interface is part of an interim API that is still under development and expected to change significantly before reaching stability. It is available at this early stage to solicit feedback from pioneering adopters on the understanding that any code that uses this API will almost certainly be broken (repeatedly) as the API evolves.

Version:
2.4.1
Author:
Pascal Filion
Since:
2.3

Field Summary
static java.lang.Object[] EMPTY_ARRAY
          The constant of an empty array.
static java.lang.String EMPTY_STRING
          The constant for an empty string.
static java.lang.String[] EMPTY_STRING_ARRAY
          The constant of an empty String array.
 
Method Summary
static java.lang.String escape(java.lang.CharSequence value, int[] position)
          Converts the escape characters contained in the given CharSequence to their literal representation.
static boolean isFunctionExpression(WordParser wordParser, java.lang.String identifier)
          Determines whether the JPQL fragment is an expression of the form <IDENTIFIER>(.
static boolean isParameter(char character)
          Determines whether the given character is the character used to identify an input parameter, either a named parameter or position parameter.
static boolean isQuote(char character)
          Determines whether the given character is the single or double quote.
static java.lang.String quote(java.lang.String text)
          Returns the given string literal by wrapping it with single quotes.
static int repositionCursor(java.lang.CharSequence query1, int position1, java.lang.CharSequence query2)
          Re-adjusts the given position, which is based on query1, by making sure it is pointing at the same position within query2.
static boolean stringIsEmpty(java.lang.CharSequence text)
          Determines whether the specified string is null, empty, or contains only whitespace characters.
static boolean stringIsNotEmpty(java.lang.CharSequence text)
          Determines whether the specified string is NOT null, NOT empty, or contains at least one non-whitespace character.
static boolean stringsAreDifferentIgnoreCase(java.lang.CharSequence value1, java.lang.CharSequence value2)
          Determines whether the two sequence of characters are different, with the appropriate null checks and the case is ignored.
static boolean stringsAreEqualIgnoreCase(java.lang.CharSequence value1, java.lang.CharSequence value2)
          Determines whether the two sequence of characters are equal or equivalent, with the appropriate null checks and the case is ignored.
static java.lang.String unescape(java.lang.CharSequence value, int[] position)
          Converts the string representation of the escape characters contained by the given CharSequence into the actual escape characters.
static java.lang.String unquote(java.lang.String text)
          Returns the string literal without the single or double quotes.
static boolean valuesAreDifferent(java.lang.Object value1, java.lang.Object value2)
          Determines whether the values are different, with the appropriate null checks.
static boolean valuesAreEqual(java.lang.Object value1, java.lang.Object value2)
          Determines whether the values are equal or equivalent, with the appropriate null checks.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

EMPTY_ARRAY

public static final java.lang.Object[] EMPTY_ARRAY
The constant of an empty array.


EMPTY_STRING

public static final java.lang.String EMPTY_STRING
The constant for an empty string.

See Also:
Constant Field Values

EMPTY_STRING_ARRAY

public static final java.lang.String[] EMPTY_STRING_ARRAY
The constant of an empty String array.

Method Detail

escape

public static java.lang.String escape(java.lang.CharSequence value,
                                      int[] position)
Converts the escape characters contained in the given CharSequence to their literal representation. For example, '\b' is converted to '\\b'.

Parameters:
value - The sequence of characters to convert any escape character
position - This is a one element array that needs to be adjusted when an escape character is converted
Returns:
The new sequence of characters that does not contain any escape character but it's literal representation

isFunctionExpression

public static boolean isFunctionExpression(WordParser wordParser,
                                           java.lang.String identifier)
Determines whether the JPQL fragment is an expression of the form <IDENTIFIER>(.

Parameters:
wordParser - The text to parse based on the current position of the cursor
identifier - The identifier to verify if it's for an expression or for possibly for a variable name
Returns:
true if the identifier is followed by '('; false otherwise

isParameter

public static boolean isParameter(char character)
Determines whether the given character is the character used to identify an input parameter, either a named parameter or position parameter.

Parameters:
character - The character to check if it's a parameter
Returns:
true if the given character is either : or ?; false otherwise

isQuote

public static boolean isQuote(char character)
Determines whether the given character is the single or double quote.

Parameters:
character - The character to check if it's a quote
Returns:
true if the given character is either ' or "; false otherwise

quote

public static java.lang.String quote(java.lang.String text)
Returns the given string literal by wrapping it with single quotes. Any single quote within the string will be escaped with another single quote.

Parameters:
text - The original text to quote
Returns:
The quoted text
Since:
2.4

repositionCursor

public static int repositionCursor(java.lang.CharSequence query1,
                                   int position1,
                                   java.lang.CharSequence query2)
Re-adjusts the given position, which is based on query1, by making sure it is pointing at the same position within query2. Usually the position is moved because the two queries don't have the same amount of whitespace.

Parameters:
query1 - The query associated to the position
position1 - The position within query1
query2 - The query for which the position might need adjustment
Returns:
The adjusted position by moving it based on the difference between query1 and query2

stringIsEmpty

public static boolean stringIsEmpty(java.lang.CharSequence text)
Determines whether the specified string is null, empty, or contains only whitespace characters.

Parameters:
text - The sequence of character to test if it is null or only contains whitespace
Returns:
true if the given string is null or only contains whitespace; false otherwise

stringIsNotEmpty

public static boolean stringIsNotEmpty(java.lang.CharSequence text)
Determines whether the specified string is NOT null, NOT empty, or contains at least one non-whitespace character.

Parameters:
text - The sequence of character to test if it is NOT null or does not only contain whitespace
Returns:
true if the given string is NOT null or has at least one non-whitespace character; false otherwise

stringsAreDifferentIgnoreCase

public static boolean stringsAreDifferentIgnoreCase(java.lang.CharSequence value1,
                                                    java.lang.CharSequence value2)
Determines whether the two sequence of characters are different, with the appropriate null checks and the case is ignored.

Parameters:
value1 - The first value to check for equality and equivalency
value2 - The second value to check for equality and equivalency
Returns:
true if both values are different; false otherwise

stringsAreEqualIgnoreCase

public static boolean stringsAreEqualIgnoreCase(java.lang.CharSequence value1,
                                                java.lang.CharSequence value2)
Determines whether the two sequence of characters are equal or equivalent, with the appropriate null checks and the case is ignored.

Parameters:
value1 - The first value to check for equality and equivalency
value2 - The second value to check for equality and equivalency
Returns:
true if both values are null, equal or equivalent; false otherwise

unescape

public static java.lang.String unescape(java.lang.CharSequence value,
                                        int[] position)
Converts the string representation of the escape characters contained by the given CharSequence into the actual escape characters. For example, the string '\\b' is converted into the character value '\b'.

Parameters:
value - The sequence of characters to convert to an escaped version
position - This is a one element array that needs to be adjusted when an escape character is converted
Returns:
The new sequence of characters that contains escape characters rather than their string representation

unquote

public static java.lang.String unquote(java.lang.String text)
Returns the string literal without the single or double quotes. Any two consecutive single quotes will be converted into a single quote.

Parameters:
text - The original text to unquote if it has ' at the beginning and the end
Returns:
The unquoted text

valuesAreDifferent

public static boolean valuesAreDifferent(java.lang.Object value1,
                                         java.lang.Object value2)
Determines whether the values are different, with the appropriate null checks.

Parameters:
value1 - The first value to check for equality and equivalency
value2 - The second value to check for equality and equivalency
Returns:
true if both values are different; true if they are both null, equal or equivalent

valuesAreEqual

public static boolean valuesAreEqual(java.lang.Object value1,
                                     java.lang.Object value2)
Determines whether the values are equal or equivalent, with the appropriate null checks.

Parameters:
value1 - The first value to check for equality and equivalency
value2 - The second value to check for equality and equivalency
Returns:
true if both values are null, equal or equivalent; false otherwise

EclipseLink 2.4.1, build 'v20121003-ad44345' API Reference