|
Oracle Fusion Middleware Java API Reference for Oracle TopLink 11g Release 1 (11.1.1) E28847-01 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object
org.eclipse.persistence.jpa.internal.jpql.WordParser
public final class WordParser
This "parser" holds onto the string version of the Java Persistence query that is parsed into a parsed tree. It uses a cursor that let the current Expression
object to parse its section of the query.
Field Summary | |
---|---|
private int |
cursor The current position of the cursor within the text. |
private int |
length The total length of the string. |
private java.lang.CharSequence |
text The string representation of the Java Persistence query to parse. |
Constructor Summary | |
---|---|
WordParser(java.lang.CharSequence query) Creates a new WordParser . |
Method Summary | |
---|---|
char |
character() Retrieves the character at the current position of the cursor. |
char |
character(int position) Retrieves the character at the given position. |
private void |
checkText(java.lang.CharSequence query) |
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. |
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. |
boolean |
isArithmeticSymbol(char character) Determines whether the given character is an arithmetic symbol, which is one of the following: { '>', '<', '/', '*', '-', '+', '=', '{' }. |
boolean |
isDelimitor(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 |
isParsingComplete(char character) |
boolean |
isTail() Determines whether the position of the cursor is at the end of the text. |
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. |
void |
moveForward(java.lang.CharSequence word) Moves the position of the cursor by the length of the given word. |
void |
moveForward(int position) Moves forward the position of the cursor by the given amount. |
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. |
java.lang.String |
potentialWord() Retrieves |
int |
potentialWordEndPosition() Retrieves |
java.lang.String |
previousWord(int position) Retrieves the previous word from the current position. |
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 prefix) |
boolean |
startsWithIdentifier(java.lang.CharSequence prefix, int toffset) |
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 at which a word ends, the position is determined by the current position of the cursor. |
int |
wordEndPosition(int position) Returns the position at which a word ends. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
private int cursor
private final int length
private final java.lang.CharSequence text
Constructor Detail |
---|
public WordParser(java.lang.CharSequence query)
WordParser
.
text
- The string representation of the Java Persistence query to parseMethod Detail |
---|
public char character()
public char character(int position)
position
- The position of the character to returnprivate void checkText(java.lang.CharSequence query)
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 texttrue
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 wordpublic boolean isArithmeticSymbol(char character)
character
- The character to test if it's a math symboltrue
if the given character is one of the valid math symbols; false
otherwisepublic boolean isDelimitor(char character)
character
- The character to testtrue
if the given character is a delimiter; false
otherwisepublic boolean isDigit(char character)
character
- The character to test if it's a digittrue
if the given character is a digit; false
otherwisepublic boolean isParsingComplete(char character)
public boolean isTail()
true
if the position of the cursor is at the end of the text; false
otherwisepublic 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 void moveForward(java.lang.CharSequence word)
word
- The word used to determine how much to move the position forwardpublic void moveForward(int position)
position
- The amount to add to the current positionpublic 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 cursorpublic int partialWordStartPosition(int position)
For instance, "SELECT AVG(e.age) FROM Employee e":
position
- The position from which the search endspublic int position()
public java.lang.String potentialWord()
public int potentialWordEndPosition()
public java.lang.String previousWord(int position)
For instance, "SELECT AVG(e.age) FROM Employee e":
position
- The position to start looking for a word in reversepublic void setPosition(int position)
position
- The new position of the cursorpublic int skipLeadingWhitespace()
text
- The text to have the whitespace removed from the beginning of the stringpublic boolean startsWith(char possibleCharacter)
possibleCharacter
- The possible character at the current positiontrue
if the text starts with the given character at the current position; false
otherwisepublic boolean startsWith(java.lang.CharSequence prefix)
prefix
- The prefixtrue
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 prefixoffset
- Where to begin looking in the querytrue
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 prefix)
public boolean startsWithIdentifier(java.lang.CharSequence prefix, int toffset)
public boolean startsWithIgnoreCase(char possibleCharacter)
possibleCharacter
- The possible character at the current positiontrue
if the text starts with the given character at the current position; false
otherwisepublic boolean startsWithIgnoreCase(java.lang.CharSequence prefix)
prefix
- The prefixtrue
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 prefixoffset
- Where to begin looking in this stringtrue
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, inclusivepublic java.lang.String substring(int startIndex, int endIndex)
startIndex
- The beginning of the substring, inclusiveendIndex
- The end of the substring, exclusivepublic 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 startspublic java.lang.String word()
public int wordEndPosition()
public int wordEndPosition(int position)
position
- The beginning of the search where the word ends
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |