|
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.parser.AbstractExpression
public abstract class AbstractExpression
This is the abstract definition of all the parts used to create the tree hierarchy representing the parsed JPQL query.
ExpressionFactory
,
JPQLGrammar
Field Summary | |
---|---|
static char |
COMMA
The constant for ','. |
static char |
DOT
The constant for '.'. |
static char |
DOUBLE_QUOTE
The constant for '"'. |
static char |
LEFT_CURLY_BRACKET
The constant for '{'. |
static char |
LEFT_PARENTHESIS
The constant for '('. |
static char |
NOT_DEFINED
The constant for a character that is not defined. |
static char |
RIGHT_CURLY_BRACKET
The constant for '}'. |
static char |
RIGHT_PARENTHESIS
The constant for ')'. |
static char |
SINGLE_QUOTE
The constant for '''. |
static char |
SPACE
The constant for ' '. |
static char |
UNDERSCORE
The constant for '_'. |
Constructor Summary | |
---|---|
protected |
AbstractExpression(AbstractExpression parent)
Creates a new AbstractExpression . |
protected |
AbstractExpression(AbstractExpression parent,
java.lang.String text)
Creates a new AbstractExpression . |
Method Summary | |
---|---|
protected boolean |
acceptUnknownVisitor(ExpressionVisitor visitor)
The given ExpressionVisitor needs to visit this class but it is defined by a third-
party provider. |
protected void |
acceptUnknownVisitor(ExpressionVisitor visitor,
java.lang.Class<?> type,
java.lang.Class<?> parameterType)
The given ExpressionVisitor needs to visit this class but it is defined by a third-
party provider. |
protected void |
addChildrenTo(java.util.Collection<Expression> children)
Adds the children of this AbstractExpression to the given collection. |
protected void |
addOrderedChildrenTo(java.util.List<Expression> children)
Adds the children of this AbstractExpression to the given list. |
protected AbstractExpression |
buildExpressionFromFallingBack(WordParser wordParser,
java.lang.String word,
JPQLQueryBNF queryBNF,
AbstractExpression expression,
boolean tolerant)
No factories were found to create an Expression with the content of WordParser ,
this method will retrieve the fallback ExpressionFactory defined in the given BNF . |
protected AbstractExpression |
buildNullExpression()
Creates a new null -Expression parented with this one. |
protected Expression |
buildStringExpression(char value)
Creates a new Expression wrapping the given character value. |
protected Expression |
buildStringExpression(java.lang.String value)
Creates a new Expression wrapping the given string value. |
protected AbstractExpression |
buildUnknownExpression(java.lang.String text)
Creates an Expression that contains an malformed expression. |
protected int |
calculatePosition(Expression expression,
int length)
Calculates the position of the given Expression by calculating the length of what is before. |
IterableListIterator<Expression> |
children()
Returns the children of this Expression . |
protected ExpressionFactory |
findFallBackExpressionFactory(JPQLQueryBNF queryBNF)
Retrieve the ExpressionFactory from the given JPQLQueryBNF by following the
path of fallback JPQLQueryBNFs and then returns the ExpressionFactory
from the leaf JPQLQueryBNF . |
JPQLQueryBNF |
findQueryBNF(Expression expression)
Retrieves the JPQLQueryBNF that represents the fragment of this Expression
that was used when parsing the given Expression . |
protected ExpressionFactory |
getExpressionFactory(java.lang.String expressionFactoryId)
Retrieves the registered ExpressionFactory that was registered for the given unique
identifier. |
protected ExpressionRegistry |
getExpressionRegistry()
Returns the registry containing the JPQLQueryBNFs and the ExpressionFactories that are used
to properly parse a JPQL query. |
JPQLGrammar |
getGrammar()
Returns the JPQLGrammar that defines how the JPQL query was parsed. |
JPAVersion |
getIdentifierVersion(java.lang.String identifier)
Retrieves the JPA version in which the identifier was first introduced. |
protected JPAVersion |
getJPAVersion()
Returns the version of the Java Persistence to support. |
int |
getLength()
Returns the length of the string representation of this Expression , which is the
length of the text generated by Expression.toActualText() . |
int |
getOffset()
Returns the position of this Expression within its parent hierarchy. |
AbstractExpression |
getParent()
Returns the parent of this Expression . |
JPQLQueryBNF |
getQueryBNF(java.lang.String queryBNFID)
Retrieves the BNF object that was registered for the given unique identifier. |
JPQLExpression |
getRoot()
Retrieves the root node of the parsed tree hierarchy. |
protected java.lang.String |
getText()
Returns the encapsulated text of this AbstractExpression , which can be used in various
ways, it can be a keyword, a literal, etc. |
protected boolean |
handleAggregate(JPQLQueryBNF queryBNF)
Determines whether the given JPQLQueryBNF handles aggregate expressions. |
protected boolean |
handleCollection(JPQLQueryBNF queryBNF)
Determines whether the given JPQLQueryBNF handles a collection of sub-expressions that
are separated by commas. |
boolean |
isAncestor(Expression expression)
Determines whether this Expression is a parent of the given Expression . |
protected boolean |
isIdentifier(java.lang.String word)
Determines if the given word is a JPQL identifier. |
protected boolean |
isNull()
Determines whether this expression is a null Expression or any other subclass. |
protected boolean |
isParsingComplete(WordParser wordParser,
java.lang.String word,
Expression expression)
Determines whether the parsing is complete based on what is left in the given text. |
protected boolean |
isTolerant()
Determines if the parser is in tolerant mode or is in fast mode. |
protected boolean |
isUnknown()
Determines whether this expression is an unknown Expression or any other subclass. |
protected boolean |
isVirtual()
Determines whether this AbstractExpression is virtual, meaning it's not part of the
query but is required for proper navigability. |
IterableListIterator<Expression> |
orderedChildren()
Returns the list representing this Expression and its children. |
protected abstract void |
parse(WordParser wordParser,
boolean tolerant)
Parses the query by starting at the current position, which is part of the given WordParser . |
protected AbstractExpression |
parse(WordParser wordParser,
java.lang.String queryBNFId,
boolean tolerant)
Parses the given text by using the specified BNF. |
protected AbstractExpression |
parseUsingExpressionFactory(WordParser wordParser,
java.lang.String queryBNFId,
boolean tolerant)
Right away parses the text by retrieving the ExpressionFactory for the first word that
is extracted from WordParser at the current location. |
void |
populatePosition(QueryPosition queryPosition,
int position)
Retrieves the Expression located at the given position using the actual query,
which may have extra whitespace. |
protected void |
rebuildActualText()
Rebuilds the actual parsed text if it has been cached. |
protected void |
rebuildParsedText()
Rebuilds the parsed parsed text if it has been cached. |
protected void |
setParent(AbstractExpression parent)
Re-parents this Expression to be a child of the given Expression . |
protected void |
setText(java.lang.String text)
Sets the text of this Expression . |
protected boolean |
shouldParseWithFactoryFirst()
Determines whether the parsing of the query should be performed using the factories first or it should automatically fallback to the fallback factory. |
protected boolean |
shouldSkipLiteral(AbstractExpression expression)
When parsing an invalid or incomplete query, it is possible two literals would be parsed but in some cases, a CollectionExpression should not be created and the parsing should actually stop here. |
java.lang.String |
toActualText()
Generates a string representation of this Expression , which needs to include any
characters that are considered virtual, i.e. that was parsed when the query is incomplete and
is needed for functionality like content assist. |
java.lang.String |
toParsedText()
Returns a string representation of this Expression and its children. |
protected abstract void |
toParsedText(java.lang.StringBuilder writer,
boolean actual)
Generates a string representation of this Expression , including its children,
if it has any. |
java.lang.String |
toString()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.eclipse.persistence.jpa.jpql.parser.Expression |
---|
accept, acceptChildren, getQueryBNF |
Field Detail |
---|
public static final char COMMA
public static final char DOT
public static final char DOUBLE_QUOTE
public static final char LEFT_CURLY_BRACKET
public static final char LEFT_PARENTHESIS
public static final char NOT_DEFINED
public static final char RIGHT_CURLY_BRACKET
public static final char RIGHT_PARENTHESIS
public static final char SINGLE_QUOTE
public static final char SPACE
public static final char UNDERSCORE
Constructor Detail |
---|
protected AbstractExpression(AbstractExpression parent)
AbstractExpression
.
parent
- The parent of this expressionprotected AbstractExpression(AbstractExpression parent, java.lang.String text)
AbstractExpression
.
parent
- The parent of this expressiontext
- The text to be stored in this expression, null
cannot be passedMethod Detail |
---|
protected boolean acceptUnknownVisitor(ExpressionVisitor visitor)
ExpressionVisitor
needs to visit this class but it is defined by a third-
party provider. This method will programmatically invoke the visit method defined on
the visitor. The method signature should be:
{public|protected|private} void visit(ThirdPartyExpression expression)
or
{public|protected|private} void visit(Expression expression)
Note: The package protected visibility (default) should be used with care, if the code is running inside OSGi, then the method will not be accessible, even through reflection.
visitor
- The ExpressionVisitor
to visit this Expression
programmatically
true
if the call was successfully executed; false
otherwiseprotected void acceptUnknownVisitor(ExpressionVisitor visitor, java.lang.Class<?> type, java.lang.Class<?> parameterType) throws java.lang.NoSuchMethodException, java.lang.IllegalAccessException, java.lang.reflect.InvocationTargetException
ExpressionVisitor
needs to visit this class but it is defined by a third-
party provider. This method will programmatically invoke the visit method defined on
the visitor. The method signature should be:
{public|protected|private} void visit(ThirdPartyExpression expression)
or
{public|protected|private} void visit(Expression expression)
visitor
- The ExpressionVisitor
to visit this Expression
programmaticallytype
- The type found in the hierarchy of the given ExpressionVisitor
that will
be used to retrieve the visit methodparameterType
- The parameter type of the visit method
java.lang.NoSuchMethodException
java.lang.IllegalAccessException
java.lang.reflect.InvocationTargetException
acceptUnknownVisitor(ExpressionVisitor)
protected void addChildrenTo(java.util.Collection<Expression> children)
AbstractExpression
to the given collection.
children
- The collection used to store the childrenprotected void addOrderedChildrenTo(java.util.List<Expression> children)
AbstractExpression
to the given list.
children
- The list used to store the string representation of this AbstractExpression
protected final AbstractExpression buildExpressionFromFallingBack(WordParser wordParser, java.lang.String word, JPQLQueryBNF queryBNF, AbstractExpression expression, boolean tolerant)
Expression
with the content of WordParser
,
this method will retrieve the fallback ExpressionFactory
defined in the given BNF
.
wordParser
- The text to parse based on the current position of the cursorword
- The word that was retrieved from the given text, which is the first word in the textqueryBNF
- The JPQLQueryBNF
used to determine how to parse from the current
position of the cursor within the JPQL queryexpression
- The Expression
that has just been parsed or null
tolerant
- Determines whether the parsing system should be tolerant, meaning if it should
try to parse invalid or incomplete queries
Expression
representing the given sub-queryprotected final AbstractExpression buildNullExpression()
null
-Expression
parented with this one.
null
version of an Expression
protected final Expression buildStringExpression(char value)
Expression
wrapping the given character value.
value
- The character to wrap as a Expression
Expression
representation of the given identifier where the owning
Expression
is this oneprotected final Expression buildStringExpression(java.lang.String value)
Expression
wrapping the given string value.
value
- The string to wrap as a Expression
Expression
representation of the given identifier where the owning
Expression
is this oneprotected final AbstractExpression buildUnknownExpression(java.lang.String text)
Expression
that contains an malformed expression.
text
- The text causing the expression to be malformed
Expression
where #toText()
returns the given textprotected final int calculatePosition(Expression expression, int length)
Expression
by calculating the length of what is before.
expression
- The Expression
for which its position within the parsed tree needs
to be determinedlength
- The current cursor position within the JPQL query while digging into the tree
until the searche reaches the expression
Expression
public final IterableListIterator<Expression> children()
Expression
.
children
in interface Expression
Expression
or an empty iterable iteratorprotected final ExpressionFactory findFallBackExpressionFactory(JPQLQueryBNF queryBNF)
ExpressionFactory
from the given JPQLQueryBNF
by following the
path of fallback JPQLQueryBNFs
and then returns the ExpressionFactory
from the leaf JPQLQueryBNF
.
queryBNF
- The JPQLQueryBNF
for which its associated fallback
will be searched
ExpressionFactory
linked to the given JPQLQueryBNF
or null
if none was declaredpublic JPQLQueryBNF findQueryBNF(Expression expression)
JPQLQueryBNF
that represents the fragment of this Expression
that was used when parsing the given Expression
.
findQueryBNF
in interface Expression
expression
- The Expression
that is a descendant of this one
JPQLQueryBNF
that was used to parse the given expressionprotected final ExpressionFactory getExpressionFactory(java.lang.String expressionFactoryId)
ExpressionFactory
that was registered for the given unique
identifier.
expressionFactoryId
- The unique identifier of the ExpressionFactory
to retrieve
ExpressionFactory
mapped with the given unique identifierExpressionRegistry.getExpressionFactory(String)
protected final ExpressionRegistry getExpressionRegistry()
JPQLQueryBNFs
and the ExpressionFactories
that are used
to properly parse a JPQL query.
public JPQLGrammar getGrammar()
JPQLGrammar
that defines how the JPQL query was parsed.
getGrammar
in interface Expression
JPQLGrammar
that was used to parse this Expression
public JPAVersion getIdentifierVersion(java.lang.String identifier)
protected JPAVersion getJPAVersion()
JPQLGrammar
public final int getLength()
Expression
, which is the
length of the text generated by Expression.toActualText()
.
getLength
in interface Expression
public final int getOffset()
Expression
within its parent hierarchy.
getOffset
in interface Expression
public final AbstractExpression getParent()
Expression
.
getParent
in interface Expression
Expression
, which is never null
except for the
root of the treepublic JPQLQueryBNF getQueryBNF(java.lang.String queryBNFID)
queryBNFID
- The unique identifier of the JPQLQueryBNF
to retrieve
JPQLQueryBNF
representing a section of the grammarpublic final JPQLExpression getRoot()
getRoot
in interface Expression
Expression
treeprotected java.lang.String getText()
AbstractExpression
, which can be used in various
ways, it can be a keyword, a literal, etc.
protected boolean handleAggregate(JPQLQueryBNF queryBNF)
JPQLQueryBNF
handles aggregate expressions.
queryBNF
- The JPQLQueryBNF
used to determine if the parsing should handle
aggregate expressions
true
if the given BNF handles aggregate expressions; false
otherwiseprotected boolean handleCollection(JPQLQueryBNF queryBNF)
JPQLQueryBNF
handles a collection of sub-expressions that
are separated by commas.
queryBNF
- The JPQLQueryBNF
used to determine if the parsing should handle
collection of sub-expressions
true
if the sub-expression to parse might have several sub-expressions
separated by commas; false
otherwisepublic boolean isAncestor(Expression expression)
Expression
is a parent of the given Expression
.
isAncestor
in interface Expression
expression
- The Expression
to verify its paternity with this Expression
true
if this Expression
is the same as the given Expression
or one of its parent; false
otherwiseprotected final boolean isIdentifier(java.lang.String word)
word
- The word to test if it is a JPQL identifier
true
if the word is an identifier, false
otherwiseExpressionRegistry.isIdentifier(String)
protected boolean isNull()
null
Expression
or any other subclass.
false
by defaultprotected boolean isParsingComplete(WordParser wordParser, java.lang.String word, Expression expression)
wordParser
- The text to parse based on the current position of the cursorword
- The word that was retrieved from the given text, which is the first word in the textexpression
- The Expression
that has already been parsed
true
if the text no longer can't be parsed by the current expression;
false
if more can be parsedprotected boolean isTolerant()
true
if the parsing system should parse invalid or incomplete queries;
false
when the query is well-formed and validprotected boolean isUnknown()
Expression
or any other subclass.
false
by defaultprotected boolean isVirtual()
AbstractExpression
is virtual, meaning it's not part of the
query but is required for proper navigability.
true
if this AbstractExpression
was virtually created to fully
qualify path expression; false
if it was parsedpublic final IterableListIterator<Expression> orderedChildren()
Expression
and its children.
orderedChildren
in interface Expression
Expressions
representing this Expression
protected abstract void parse(WordParser wordParser, boolean tolerant)
WordParser
.
wordParser
- The text to parse based on the current position of the cursortolerant
- Determines whether the parsing system should be tolerant, meaning if it should
try to parse invalid or incomplete queriesprotected AbstractExpression parse(WordParser wordParser, java.lang.String queryBNFId, boolean tolerant)
wordParser
- The text to parse based on the current position of the cursorqueryBNFId
- The unique identifier of the JPQLQueryBNF
that is used to determine
how to parse the text at the current cursor position within the JPQL querytolerant
- Determines whether the parsing system should be tolerant, meaning if it should
try to parse invalid or incomplete queries
Expression
representing the given sub-queryprotected AbstractExpression parseUsingExpressionFactory(WordParser wordParser, java.lang.String queryBNFId, boolean tolerant)
ExpressionFactory
for the first word that
is extracted from WordParser
at the current location.
wordParser
- The text to parse based on the current position of the cursorqueryBNFId
- The unique identifier of the JPQLQueryBNF
that is used to determine
how to parse the text at the current cursor position within the JPQL querytolerant
- Determines whether the parsing system should be tolerant, meaning if it should
try to parse invalid or incomplete queries
Expression
representing the given sub-querypublic void populatePosition(QueryPosition queryPosition, int position)
Expression
located at the given position using the actual query,
which may have extra whitespace.
populatePosition
in interface Expression
position
- The array has one element and is the position of the Expression
to retrieveprotected final void rebuildActualText()
protected final void rebuildParsedText()
protected final void setParent(AbstractExpression parent)
Expression
to be a child of the given Expression
.
parent
- The new parent of this objectprotected final void setText(java.lang.String text)
Expression
.
text
- The immutable text wrapped by this Expression
, which cannot be null
protected boolean shouldParseWithFactoryFirst()
factories
first or it should automatically fallback to the fallback factory.
true
is returned by default so the factories are used before falling backprotected boolean shouldSkipLiteral(AbstractExpression expression)
expression
- The Expression
that has just been parsed or null
true
public java.lang.String toActualText()
Expression
, which needs to include any
characters that are considered virtual, i.e. that was parsed when the query is incomplete and
is needed for functionality like content assist.
toActualText
in interface Expression
Expression
public java.lang.String toParsedText()
Expression
and its children. The expression
should contain whitespace even if the beautified version would not have any. For instance,
"SELECT e " should be returned where Expression.toParsedText()
would return "SELECT e".
toParsedText
in interface Expression
Expression
protected abstract void toParsedText(java.lang.StringBuilder writer, boolean actual)
Expression
, including its children,
if it has any.
writer
- The buffer used to append this Expression
's string representationactual
- Determines whether the string representation should represent what was parsed,
i.e. include any "virtual" whitespace (such as ending whitespace) and the actual case of the
JPQL identifierspublic final java.lang.String toString()
toString
in class java.lang.Object
|
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 |