|
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.parser.StringExpression
org.eclipse.persistence.jpa.internal.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. It has the core of the parsing engine and of the content assist behavior (retrieval of the possible expression factories
).
ExpressionFactory
, StringExpression
Field Summary | |
---|---|
private java.lang.String |
actualText The 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. |
private java.util.List<Expression> |
children The children of this AbstractExpression . |
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. |
private java.util.List<StringExpression> |
orderedChildren The string representation of this AbstractExpression . |
private AbstractExpression |
parent The parent of this expression or null if this is the root of the parsed tree hierarchy. |
private java.lang.String |
parsedText The string representation of this AbstractExpression . |
private static ExpressionRegistry |
registry This registry keeps the single instances of various portion of the parser, which should increase performance the parsing process. |
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 ' '. |
private java.lang.String |
text If this expression has an identifier or a single value, then it's possible it's using this text to store it. |
static char |
UNDERSCORE The constant for '_'. |
Constructor Summary | |
---|---|
AbstractExpression(AbstractExpression parent) Creates a new AbstractExpression . |
|
AbstractExpression(AbstractExpression parent, java.lang.String text) Creates a new AbstractExpression . |
Method Summary | ||
---|---|---|
(package private) void |
addChildrenTo(java.util.Collection<Expression> children) Adds the children of this Expression to the given collection. |
|
(package private) void |
addOrderedChildrenTo(java.util.List<StringExpression> children) Adds the StringExpressions representing this Expression . |
|
(package private) AbstractExpression |
buildExpressionFromFallingBack(WordParser wordParser, java.lang.String word, JPQLQueryBNF queryBNF, AbstractExpression expression, boolean tolerant) |
|
(package private) AbstractExpression |
buildNullExpression() Creates a new null -Expression parented with this one. |
|
(package private) StringExpression |
buildStringExpression(char value) Creates a new StringExpression wrapping the given character value. |
|
(package private) StringExpression |
buildStringExpression(java.lang.String value) Creates a new StringExpression wrapping the given string value. |
|
(package private) AbstractExpression |
buildUnknownExpression(java.lang.String text) Creates an Expression that contains an malformed expression. |
|
java.util.ListIterator<Expression> |
children() Returns the children of this Expression . |
|
(package private) static ExpressionFactory |
expressionFactory(java.lang.String expressionFactoryId) Retrieves the registered ExpressionFactory that was registered for the given unique identifier. |
|
(package private) static ExpressionFactory |
expressionFactoryForIdentifier(java.lang.String identifier) Retrieves the registered ExpressionFactory that was registered for the given unique identifier. |
|
private ExpressionFactory |
findFallBackExpressionFactory(JPQLQueryBNF queryBNF) |
|
JPQLQueryBNF |
findQueryBNF(AbstractExpression expression) Retrieves the JPQLQueryBNF that was used to parse the given Expression . |
|
Expression[] |
getChildren() Returns the children of this Expression . |
|
(package private) IJPAVersion |
getJPAVersion() Returns the version of the Java Persistence to support. |
|
AbstractExpression |
getParent() Returns the parent of this Expression . |
|
abstract JPQLQueryBNF |
getQueryBNF() Returns the BNF of this Expression . |
|
JPQLExpression |
getRoot() Retrieves the root node of the parsed tree hierarchy. |
|
(package private) 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. |
|
(package private) boolean |
handleAggregate(JPQLQueryBNF queryBNF) Determines whether the given JPQLQueryBNF handles aggregate expressions. |
|
static IdentifierRole |
identifierRole(java.lang.String identifier) Retrieves the role of the given identifier. |
|
static java.util.Collection<java.lang.String> |
identifiers() Returns the set of identifiers used by the Java Persistence query language. |
|
(package private) java.lang.Iterable<java.lang.String> |
identifiers(java.lang.String queryBNFId) Retrieves the identifiers that are supported by the given BNF. |
|
static IJPAVersion |
identifierVersion(java.lang.String identifier) Retrieves the JPA version in which the identifier was first introduced. |
|
boolean |
isAncestor(Expression expression) Determines whether this Expression is a parent of the given Expression . |
|
static boolean |
isIdentifier(java.lang.String identifier) Determines if the given word is a JPQL identifier. |
|
(package private) boolean |
isNull() Determines whether this expression is a null Expression or any other subclass. |
|
(package private) 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. |
|
(package private) boolean |
isTolerant() Determines if the parser is in tolerant mode or is in fast mode. |
|
(package private) boolean |
isUnknown() Determines whether this expression is an unknown Expression or any other subclass. |
|
private boolean |
isValidExpressionFactory(ExpressionFactory factory) |
|
boolean |
isVirtual() Determines whether this identification variable is virtual, meaning it's not part of the query but is required for proper navigability. |
|
java.util.ListIterator<StringExpression> |
orderedChildren() Creates a list representing this expression and its children. |
|
(package private) abstract void |
parse(WordParser wordParser, boolean tolerant) Parses the query by starting at the current position, which is part of the given WordParser . |
|
(package private) AbstractExpression |
parse(WordParser wordParser, JPQLQueryBNF queryBNF, boolean tolerant) Parses the given text by using the specified BNF. |
|
private AbstractExpression |
parse(WordParser wordParser, java.lang.String word, ExpressionFactory factory, JPQLQueryBNF queryBNF, AbstractExpression expression, boolean tolerant) Parses the given text. |
|
(package private) AbstractExpression |
parseSingleExpression(WordParser wordParser, JPQLQueryBNF queryBNF, boolean tolerant) Right away parses the text by retrieving the ExpressionFactory for the first word that is extracted from WordParser at the current location. |
|
(package private) void |
populatePosition(QueryPosition queryPosition, int position) Retrieves the StringExpression located at the given position using the actual query, which may have extra whitespace. |
|
static
|
queryBNF(java.lang.String queryBNFID) Retrieves the BNF object that was registered for the given unique identifier. |
|
(package private) void |
readdLeadingSpaces(java.lang.StringBuilder text, int count) Adds spaces at the front of the given text. |
|
(package private) void |
rebuildActualText() Rebuilds the actual parsed text if it has been cached. |
|
(package private) void |
rebuildParsedText() Rebuilds the parsed parsed text if it has been cached. |
|
(package private) void |
setParent(AbstractExpression parent) Re-parents this Expression to be a child of the given Expression . |
|
(package private) void |
setText(java.lang.String text) Sets the text of this Expression . |
|
(package private) boolean |
shouldParseWithFactoryFirst() TODO |
|
(package private) 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 StringExpression , 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 StringExpression and its children. |
|
(package private) abstract void |
toParsedText(java.lang.StringBuilder writer, boolean includeVirtual) Generates a string representation of this Expression . |
|
java.lang.String |
toString() |
|
private AbstractExpression |
updateParsingInfo(AbstractExpression expression, AbstractExpression child, java.util.List<AbstractExpression> children, java.util.List<java.lang.Boolean> separatedByCommas, java.util.List<java.lang.Boolean> separatedBySpaces) |
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.internal.jpql.parser.Expression |
---|
accept, acceptChildren |
Field Detail |
---|
private java.lang.String actualText
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()
private java.util.List<Expression> children
AbstractExpression
.
children()
private java.util.List<StringExpression> orderedChildren
AbstractExpression
.
orderedChildren()
private AbstractExpression parent
null
if this is the root of the parsed tree hierarchy.private java.lang.String parsedText
AbstractExpression
.
toParsedText()
private java.lang.String text
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
private static final ExpressionRegistry registry
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 |
---|
AbstractExpression(AbstractExpression parent)
AbstractExpression
.
parent
- The parent of this expressionAbstractExpression(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 |
---|
static ExpressionFactory expressionFactory(java.lang.String expressionFactoryId)
ExpressionFactory
that was registered for the given unique identifier.expressionFactoryId
- The unique identifier of the ExpressionFactory
to retrieveExpressionFactory
mapped with the given unique identifierstatic ExpressionFactory expressionFactoryForIdentifier(java.lang.String identifier)
ExpressionFactory
that was registered for the given unique identifier.expressionFactoryId
- The unique identifier of the ExpressionFactory
to retrieveExpressionFactory
mapped with the given unique identifierpublic static IdentifierRole identifierRole(java.lang.String identifier)
identifier
- The identifier for which its role is requestedpublic static java.util.Collection<java.lang.String> identifiers()
public static IJPAVersion identifierVersion(java.lang.String identifier)
public static boolean isIdentifier(java.lang.String identifier)
word
- The word to testtrue
if the word is an identifier, false
otherwisepublic static <T extends JPQLQueryBNF> T queryBNF(java.lang.String queryBNFID)
queryBNFID
- The unique identifier of the JPQLQueryBNF
to retrieveJPQLQueryBNF
representing a section of the grammarvoid addChildrenTo(java.util.Collection<Expression> children)
Expression
to the given collection.children
- The collection used to store the childrenvoid addOrderedChildrenTo(java.util.List<StringExpression> children)
StringExpressions
representing this Expression
.children
- The list used to store the string representation of this Expression
final AbstractExpression buildExpressionFromFallingBack(WordParser wordParser, java.lang.String word, JPQLQueryBNF queryBNF, AbstractExpression expression, boolean tolerant)
final AbstractExpression buildNullExpression()
null
-Expression
parented with this one.null
version of an Expression
final StringExpression buildStringExpression(char value)
StringExpression
wrapping the given character value.value
- The character to wrap as a StringExpression
StringExpression
representation of the given identifier where the owning Expression
is this onefinal StringExpression buildStringExpression(java.lang.String value)
StringExpression
wrapping the given string value.value
- The string to wrap as a StringExpression
StringExpression
representation of the given identifier where the owning Expression
is this onefinal AbstractExpression buildUnknownExpression(java.lang.String text)
Expression
that contains an malformed expression.text
- The text causing the expression to be malformedExpression
where #toText()
returns the given textpublic final java.util.ListIterator<Expression> children()
Expression
.children
in interface Expression
Expression
or an empty list if this Expression
does not have childrenprivate ExpressionFactory findFallBackExpressionFactory(JPQLQueryBNF queryBNF)
public JPQLQueryBNF findQueryBNF(AbstractExpression expression)
JPQLQueryBNF
that was used to parse the given Expression
.expression
- The expression for which its BNF is neededJPQLQueryBNF
that was used to parse the given expressionpublic final Expression[] getChildren()
Expression
.getChildren
in interface Expression
Expression
or an empty list if this Expression
does not have childrenIJPAVersion getJPAVersion()
public final AbstractExpression getParent()
Expression
.getParent
in interface Expression
null
except for the root of the treepublic abstract JPQLQueryBNF getQueryBNF()
Expression
.JPQLQueryBNF
, which represents the grammar of this Expression
public final JPQLExpression getRoot()
getRoot
in interface Expression
Expression
treejava.lang.String getText()
AbstractExpression
, which can be used in various ways, it can be a keyword, a literal, etc.boolean handleAggregate(JPQLQueryBNF queryBNF)
JPQLQueryBNF
handles aggregate expressions.queryBNF
- The JPQLQueryBNF
used to determine if the parsing should handle aggregate expressionstrue
if the given BNF handles aggregate expressions; false
otherwisefinal java.lang.Iterable<java.lang.String> identifiers(java.lang.String queryBNFId)
queryBNFId
- The unique identifier of the BNF for which the supported identifiers are requestedpublic 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
otherwiseboolean isNull()
null
Expression
or any other subclass.false
by defaultboolean 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 parsedtrue
if the text no longer can't be parsed by the current expression; false
if more can be parsedboolean isTolerant()
true
if the parsing system should parse invalid or incomplete queries; false
when the query is well-formed and validboolean isUnknown()
Expression
or any other subclass.false
by defaultprivate boolean isValidExpressionFactory(ExpressionFactory factory)
public boolean isVirtual()
true
if this identification variable was virtually created to fully qualify path expression; false
if it was parsedpublic final java.util.ListIterator<StringExpression> orderedChildren()
#addChildrenTo(Collection)
is called.orderedChildren
in class StringExpression
StringExpressions
representing this Expression
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 queriesAbstractExpression parse(WordParser wordParser, JPQLQueryBNF queryBNF, boolean tolerant)
wordParser
- The text to parse based on the current position of the cursorqueryBNF
- The grammar used to retrieve the possible expression factories
tolerant
- Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queriesExpression
representing the given sub-queryprivate AbstractExpression parse(WordParser wordParser, java.lang.String word, ExpressionFactory factory, JPQLQueryBNF queryBNF, AbstractExpression expression, boolean tolerant)
ExpressionFactory
, then the factory is used to create the expression.wordParser
- The text to parse based on the current position of the cursorword
- The current word to parsefactory
- The factory used to determine if the text matches the criteria for it to create the expressionqueryBNF
- The BNF helping to parse the queryexpression
- The expression parsed prior to parse the texttolerant
- Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queriesnull
if the text doesn't meet the criteria of the factoryAbstractExpression parseSingleExpression(WordParser wordParser, JPQLQueryBNF queryBNF, 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 cursorqueryBNF
- The grammar used to retrieve the expression factory
tolerant
- Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queriesExpression
representing the given sub-queryfinal void populatePosition(QueryPosition queryPosition, int position)
StringExpression
located at the given position using the actual query, which may have extra whitespace.populatePosition
in class StringExpression
position
- The array has one element and is the position of the StringExpression
to retrievefinal void readdLeadingSpaces(java.lang.StringBuilder text, int count)
text
- The text to have spaces added at its beginningcount
- The number of spaces to addfinal void rebuildActualText()
final void rebuildParsedText()
final void setParent(AbstractExpression parent)
Expression
to be a child of the given Expression
.parent
- The new parent of this objectfinal void setText(java.lang.String text)
Expression
.text
- The immutable text wrapped by this Expression
, which cannot be null
boolean shouldParseWithFactoryFirst()
boolean shouldSkipLiteral(AbstractExpression expression)
expression
-public java.lang.String toActualText()
StringExpression
, 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
toActualText
in class StringExpression
StringExpression
public java.lang.String toParsedText()
StringExpression
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#toText()
would return "SELECT e".toParsedText
in interface Expression
toParsedText
in class StringExpression
StringExpression
abstract void toParsedText(java.lang.StringBuilder writer, boolean includeVirtual)
Expression
.writer
- The buffer used to append this Expression
's string representationincludeVirtual
- Determines whether 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 assistpublic final java.lang.String toString()
toString
in class java.lang.Object
private AbstractExpression updateParsingInfo(AbstractExpression expression, AbstractExpression child, java.util.List<AbstractExpression> children, java.util.List<java.lang.Boolean> separatedByCommas, java.util.List<java.lang.Boolean> separatedBySpaces)
|
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |