|
EclipseLink 2.4.2, build 'v20130514-5956486' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.eclipse.persistence.jpa.jpql.ExpressionTools
public final class ExpressionTools
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.
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 |
isJavaEscapedCharacter(char character)
Determines whether the given character should be escaped when being part of a string, i.e. |
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 void |
reposition(java.lang.CharSequence query1,
int[] positions,
java.lang.CharSequence query2)
Adjusts the positions contained by the given array of either one or two elements, which is based on the given query1, by translating those positions to be at the equivalent position within query2. |
static int |
repositionCursor(java.lang.CharSequence query1,
int position1,
java.lang.CharSequence query2)
Adjusts the position, which is based on the given query1, by translating it to be at the equivalent position within query2. |
static void |
repositionJava(java.lang.CharSequence query,
int[] positions)
Re-adjusts the given positions, which is based on the non-escaped version of the given query, by making sure it is pointing at the same position within query, which contains references (escape characters). |
static boolean |
startWithIgnoreCase(java.lang.String string,
java.lang.String prefix)
Determines whether the given string starts with the given prefix and ignores the case. |
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 |
---|
public static final java.lang.Object[] EMPTY_ARRAY
public static final java.lang.String EMPTY_STRING
public static final java.lang.String[] EMPTY_STRING_ARRAY
Method Detail |
---|
public static java.lang.String escape(java.lang.CharSequence value, int[] position)
CharSequence
to their literal
representation. For example, '\b' is converted to '\\b'.
value
- The sequence of characters to convert any escape characterposition
- This is a one element array that needs to be adjusted when an escape
character is converted
public static boolean isFunctionExpression(WordParser wordParser, java.lang.String identifier)
<IDENTIFIER>(
.
wordParser
- The text to parse based on the current position of the cursoridentifier
- The identifier to verify if it's for an expression or for possibly for a
variable name
true
if the identifier is followed by '('; false
otherwisepublic static boolean isJavaEscapedCharacter(char character)
character
- The character to check if it can directly be used in a string or should be escaped
true
if the given character cannot be used directly in a stringpublic static boolean isParameter(char character)
character
- The character to check if it's a parameter
true
if the given character is either : or ?; false
otherwisepublic static boolean isQuote(char character)
character
- The character to check if it's a quote
true
if the given character is either ' or "; false
otherwisepublic static java.lang.String quote(java.lang.String text)
text
- The original text to quote
public static void reposition(java.lang.CharSequence query1, int[] positions, java.lang.CharSequence query2)
Important: The two JPQL queries should contain the same characters but the amount of whitespace can differ. One cannot have the escape characters and the other one has the Unicode characters.
query1
- The query where the positions are pointingpositions
- An array of either one or two elements positioned within query1query2
- The query for which the positions might need adjustmentpublic static int repositionCursor(java.lang.CharSequence query1, int position1, java.lang.CharSequence query2)
Important: The two JPQL queries should contain the same characters but the amount of whitespace can differ. One cannot have the escape characters and the other one has the Unicode characters.
query1
- The query where the positions are pointingposition
- The position of a cursor within query1query2
- The query for which the position might need adjustment
reposition(CharSequence, int[], CharSequence)
public static void repositionJava(java.lang.CharSequence query, int[] positions)
The escape characters are either \b, \t, \n, \f, \r, \", \' and \0 through \7.
Important: The given query should contain the exact same amount of whitespace than the query used to calculate the given positions.
query
- The query that may contain escape characterspositions
- The position within the non-escaped version of the given query, which is
either a single element position or two positions that is used as a text rangepublic static boolean startWithIgnoreCase(java.lang.String string, java.lang.String prefix)
null
or an empty string, then true
is always returned.
string
- The string to check if its beginning matches the prefixprefix
- The prefix used to test matching the beginning of the sequence of characters
true
if the given string begins with the given prefix and ignores the
case; false
otherwisepublic static boolean stringIsEmpty(java.lang.CharSequence text)
null
, empty, or contains only
whitespace characters.
text
- The sequence of character to test if it is null
or only contains
whitespace
true
if the given string is null
or only contains whitespace;
false
otherwisepublic static boolean stringIsNotEmpty(java.lang.CharSequence text)
null
, NOT empty, or contains at
least one non-whitespace character.
text
- The sequence of character to test if it is NOT null
or does not only
contain whitespace
true
if the given string is NOT null
or has at least one
non-whitespace character; false
otherwisepublic static boolean stringsAreDifferentIgnoreCase(java.lang.CharSequence value1, java.lang.CharSequence value2)
null
checks and the case is ignored.
value1
- The first value to check for equality and equivalencyvalue2
- The second value to check for equality and equivalency
true
if both values are different; false
otherwisepublic static boolean stringsAreEqualIgnoreCase(java.lang.CharSequence value1, java.lang.CharSequence value2)
null
checks and the case is ignored.
value1
- The first value to check for equality and equivalencyvalue2
- The second value to check for equality and equivalency
true
if both values are null
, equal or equivalent;
false
otherwisepublic static java.lang.String unescape(java.lang.CharSequence value, int[] position)
CharSequence
into the actual escape characters. For example, the string '\\b' is converted
into the character value '\b'.
value
- The sequence of characters to convert to an escaped versionposition
- This is a one element array that needs to be adjusted when an escape
character is converted
public static java.lang.String unquote(java.lang.String text)
text
- The original text to unquote if it has ' at the beginning and the end
public static boolean valuesAreDifferent(java.lang.Object value1, java.lang.Object value2)
null
checks.
value1
- The first value to check for equality and equivalencyvalue2
- The second value to check for equality and equivalency
true
if both values are different; true
if they are both
null
, equal or equivalentpublic static boolean valuesAreEqual(java.lang.Object value1, java.lang.Object value2)
null
checks.
value1
- The first value to check for equality and equivalencyvalue2
- The second value to check for equality and equivalency
true
if both values are null
, equal or equivalent;
false
otherwise
|
EclipseLink 2.4.2, build 'v20130514-5956486' API Reference | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |