|
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.WordParser
public final class WordParser
This "parser/scanner" holds onto the string version of the JPQL query that is parsed into a
parsed tree. It uses a cursor that lets the current parser.Expression Expression
object to parse its fragment of the query.
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.
Nested Class Summary | |
---|---|
static class |
WordParser.WordType
This enumeration determines the type of word that was scanned. |
Constructor Summary | |
---|---|
WordParser(java.lang.CharSequence text)
Creates a new WordParser . |
Method Summary | |
---|---|
char |
character()
Retrieves the character at the current cursor position. |
char |
character(int position)
Retrieves the character at the given cursor position. |
boolean |
endsWith(int endPosition,
java.lang.String suffix)
Determines whether the query ends with the given suffix and the end position is the end of the range for testing. |
boolean |
endsWithIgnoreCase(int endPosition,
java.lang.String suffix)
Determines whether the query ends with the given suffix and the end position is the end of the range for testing. |
java.lang.String |
entireWord()
Retrieves a word starting at the current position. |
java.lang.String |
entireWord(int position)
Retrieves a word starting at the given position. |
WordParser.WordType |
getWordType()
Returns what the type of word word() returns. |
boolean |
isArithmeticSymbol(char character)
Determines whether the given character is an arithmetic symbol, which is one of the following: { '>', '<', '/', '*', '-', '+', '=', '{' }. |
boolean |
isDelimiter(char character)
Determines whether the given character is a delimiter. |
boolean |
isDigit(char character)
Determines whether the given character is a character that can be used in a number. |
boolean |
isTail()
Determines whether the position of the cursor is at the end of the text. |
boolean |
isWordSeparator(char character)
Determines whether the given character is not considered to be part of a word (which is usually comprise of alphanumeric characters). |
int |
length()
Returns the length of the string value. |
void |
moveBackward(java.lang.CharSequence word)
Moves the position of the cursor by the length of the given word. |
void |
moveBackward(int position)
Moves backward the position of the cursor by the given amount. |
java.lang.String |
moveForward(java.lang.CharSequence word)
Moves the position of the cursor by the length of the given word. |
java.lang.String |
moveForward(int position)
Moves forward the position of the cursor by the given amount. |
java.lang.String |
numericLiteral()
Retrieves the numeric literal that should be the current word to parse. |
java.lang.String |
partialWord()
Retrieves a word before the current position of the cursor, which determines when the parsing stop. |
java.lang.String |
partialWord(int position)
Retrieves a word before the specified position, which determines when the parsing stop. |
int |
partialWordStartPosition(int position)
Finds the beginning of the word and the given position is within that word. |
int |
position()
Returns the current position of the cursor. |
void |
setPosition(int position)
Manually sets the position of the cursor within the string. |
int |
skipLeadingWhitespace()
Removes the whitespace that starts the given text. |
boolean |
startsWith(char possibleCharacter)
Determines whether the text starts with the given character. |
boolean |
startsWith(java.lang.CharSequence prefix)
Tests whether the query starts with the specified prefix from the current position. |
boolean |
startsWith(java.lang.CharSequence prefix,
int startIndex)
Tests whether the substring of the query beginning at the specified index starts with the specified prefix. |
boolean |
startsWithArithmeticOperator()
Determines whether the character at the current position is one of the arithmetic operators: { '+', '-', '*', '/' }, |
java.lang.Boolean |
startsWithDigit()
Determines if the text starts with a digit ( true ), an arithmetic term
(false ) or anything else (null ). |
boolean |
startsWithIdentifier(java.lang.CharSequence identifier)
Determines whether the text at the current position start with the following identifier. |
boolean |
startsWithIdentifier(java.lang.CharSequence identifier,
int position)
Determines whether the text at the current position start with the following identifier. |
boolean |
startsWithIgnoreCase(char possibleCharacter)
Determines whether the text starts with the given character. |
boolean |
startsWithIgnoreCase(java.lang.CharSequence prefix)
Tests if the string starts with the specified prefix. |
boolean |
startsWithIgnoreCase(java.lang.CharSequence prefix,
int offset)
Tests if the string starts with the specified prefix. |
java.lang.String |
substring()
Returns a substring that is within the current position of the cursor and the end of the text. |
java.lang.String |
substring(int startIndex)
Returns a substring that is within the given position and the end of the text. |
java.lang.String |
substring(int startIndex,
int endIndex)
Returns a substring that is within the given positions. |
java.lang.String |
toString()
|
int |
whitespaceCount()
Calculates the number of whitespace that are in the query. |
int |
whitespaceCount(int position)
Calculates the number of whitespace that are in the query. |
java.lang.String |
word()
Retrieves the first word starting at the current position. |
int |
wordEndPosition()
Returns the position a word would end based on the current cursor position. |
int |
wordEndPosition(int position)
Returns the position a word would end based on the given start position. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public WordParser(java.lang.CharSequence text)
WordParser
.
text
- The string representation of the JPQL queryMethod Detail |
---|
public char character()
public char character(int position)
position
- The position of the character to return
public boolean endsWith(int endPosition, java.lang.String suffix)
endPosition
- The position where the check stopssuffix
- The suffix is the text that is used to match it with the substring within the text
true
if the character sequence represented by the argument is a suffix of
the query; false
otherwisepublic boolean endsWithIgnoreCase(int endPosition, java.lang.String suffix)
endPosition
- The position where the check stopssuffix
- The suffix is the text that is used to match it with the substring within the text
true
if the character sequence represented by the argument is a suffix of
the query; false
otherwisepublic java.lang.String entireWord()
For instance, "SELECT AVG(e.age) FROM Employee e":
public java.lang.String entireWord(int position)
For instance, "SELECT AVG(e.age) FROM Employee e":
position
- The position where to retrieve the word
public WordParser.WordType getWordType()
word()
returns.
word()
public boolean isArithmeticSymbol(char character)
character
- The character to test if it's a math symbol
true
if the given character is one of the valid math symbols;
false
otherwisepublic boolean isDelimiter(char character)
character
- The character to test
true
if the given character is a delimiter; false
otherwisepublic boolean isDigit(char character)
character
- The character to test if it's a digit
true
if the given character is a digit; false
otherwisepublic boolean isTail()
true
if the position of the cursor is at the end of the text;
false
otherwisepublic boolean isWordSeparator(char character)
character
- The character used to determine if it should be part of a word or not
true
if the character can be part of a word; false
if it is
not an alphanumeric character, which usually means is a whitespace, a delimiter or an
arithmetic symbolCharacter.isWhitespace(char)
,
isArithmeticSymbol(char)
,
#isDelimitor(char)
public int length()
public void moveBackward(java.lang.CharSequence word)
word
- The word used to determine how much to move the position forwardpublic void moveBackward(int position)
position
- The amount to remove from the current positionpublic java.lang.String moveForward(java.lang.CharSequence word)
word
- The word used to determine how much to move the position forward
public java.lang.String moveForward(int position)
position
- The amount to add to the current position
public java.lang.String numericLiteral()
public java.lang.String partialWord()
For instance, "SELECT AVG(e.age) FROM Employee e":
public java.lang.String partialWord(int position)
For instance, "SELECT AVG(e.age) FROM Employee e":
position
- The position of the cursor
public int partialWordStartPosition(int position)
For instance, "SELECT AVG(e.age) FROM Employee e":
position
- The position from which the search ends
public int position()
public void setPosition(int position)
position
- The new position of the cursorpublic int skipLeadingWhitespace()
public boolean startsWith(char possibleCharacter)
possibleCharacter
- The possible character at the current position
true
if the text starts with the given character at the current position;
false
otherwisepublic boolean startsWith(java.lang.CharSequence prefix)
prefix
- The prefix
true
if the character sequence represented by the argument is a prefix of
the text; false
otherwisepublic boolean startsWith(java.lang.CharSequence prefix, int startIndex)
prefix
- The prefixstartIndex
- Where to begin looking in the query
true
if the character sequence represented by the
argument is a prefix of the substring of this object starting at index startIndex
;
false
otherwisepublic boolean startsWithArithmeticOperator()
true
if the character at the current position is an arithmetic operator;
false
otherwisepublic java.lang.Boolean startsWithDigit()
true
), an arithmetic term
(false
) or anything else (null
).
true
if the text starts with a digit (we'll assume it is a digit if the
text starts with a digit or an arithmetic sign followed by a digit), false
if it
starts with an arithmetic term (we'll assume it is a digit followed by a non-digit character);
otherwise returns null
public boolean startsWithIdentifier(java.lang.CharSequence identifier)
identifier
- The JPQL identifier to match with the text at the current position
true
if the text starts with the given text (case is ignored) and the
cursor is at the end of the text or is following by a word separator character; false
otherwisepublic boolean startsWithIdentifier(java.lang.CharSequence identifier, int position)
position
- The position to start matching the charactersidentifier
- The JPQL identifier to match with the text at the current position
true
if the text starts with the given text (case is ignored) and the
cursor is at the end of the text or is following by a word separator character; false
otherwisepublic boolean startsWithIgnoreCase(char possibleCharacter)
possibleCharacter
- The possible character at the current position
true
if the text starts with the given character at the current position;
false
otherwisepublic boolean startsWithIgnoreCase(java.lang.CharSequence prefix)
prefix
- The prefix to test against
true
if the character sequence represented by the argument is a prefix of
the character sequence represented by this string; false
otherwise. Note also
that true
will be returned if the argument is an empty string or is equal to this
String
object as determined by the Object.equals(Object)
methodpublic boolean startsWithIgnoreCase(java.lang.CharSequence prefix, int offset)
prefix
- The prefix to test againstoffset
- Where to begin looking in this string
true
if the character sequence represented by the argument is a prefix of
the character sequence represented by this string; false
otherwisepublic java.lang.String substring()
public java.lang.String substring(int startIndex)
startIndex
- The beginning of the substring, inclusive
public java.lang.String substring(int startIndex, int endIndex)
startIndex
- The beginning of the substring, inclusiveendIndex
- The end of the substring, exclusive
public java.lang.String toString()
toString
in class java.lang.Object
public int whitespaceCount()
public int whitespaceCount(int position)
position
- The position from where the scan starts
public java.lang.String word()
public int wordEndPosition()
getWordType()
can be used to determine the type of word that was scanned.
WordParser.word()
,
WordParser.WordType
public int wordEndPosition(int position)
getWordType()
can be used to determine the type of word that was scanned.
position
- The position to start scanning the text
WordParser.word()
,
WordParser.WordType
|
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 |