JPQLExpression is the root of the parsed tree representation of a JPQL query. The
query is parsed based on what was registered in the JPQLGrammar's ExpressionRegistry.
A JPQL statement may be either a SELECT statement, an UPDATE statement, or a DELETE FROM statement.
QL_statement ::= select_statement |
update_statement |
delete_statement
It is possible to parse a portion of a JPQL query. The ID of the JPQLQueryBNF is used to
parse that portion and getQueryStatement() then returns only the parsed tree representation
of that JPQL fragment.
| Modifier and Type | Field and Description |
|---|---|
| private JPQLGrammar | jpqlGrammar
The JPQL grammar that defines how to parse a JPQL query. |
| private String | queryBNFId
By default, this is |
| private AbstractExpression | queryStatement
The tree representation of the query. |
| private boolean | tolerant
Determines if the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries. |
| private AbstractExpression | unknownEndingStatement
If the expression could not be fully parsed, meaning some unknown text is trailing the query, this will contain it. |
| Access | Constructor and Description |
|---|---|
| public | JPQLExpression(CharSequence
The string representation of the JPQL query to parse query, JPQLGrammar The JPQL grammar that defines how to parse a JPQL query jpqlGrammar)Creates a new |
| public | JPQLExpression(CharSequence
The string representation of the JPQL query to parse query, JPQLGrammar The JPQL grammar that defines how to parse a JPQL query jpqlGrammar, boolean Determines if the parsing system should be tolerant, meaning if it should try
to parse invalid or incomplete queries tolerant)Creates a new |
| public | JPQLExpression(CharSequence
A fragment of a JPQL query, which is a portion of a complete JPQL query jpqlFragment, JPQLGrammar The JPQL grammar that defines how to parse a JPQL query jpqlGrammar, String The unique identifier of the queryBNFId, boolean JPQLQueryBNFDetermines if the parsing system should be tolerant, meaning if it should try
to parse invalid or incomplete queries tolerant)Creates a new |
| private | JPQLExpression(JPQLGrammar
The JPQL grammar that defines how to parse a JPQL query jpqlGrammar, String queryBNFId, boolean Determines if the parsing system should be tolerant, meaning if it should try
to parse invalid or incomplete queries tolerant)Creates a new |
| Modifier and Type | Method and Description |
|---|---|
| public void | accept(ExpressionVisitor
The visitor)ExpressionVisitor to visit this objectImplements org. Expression by the given visitor.
|
| public void | acceptChildren(ExpressionVisitor
The visitor)visitor to visit the children of this object.Implements org. Expression.
|
| protected void | addChildrenTo(Collection<Expression>
The collection used to store the children children)Overrides org. AbstractExpression to the given collection.
|
| protected void | addOrderedChildrenTo(List<Expression>
The list used to store the string representation of this children)AbstractExpressionOverrides org. AbstractExpression to the given list.
|
| public QueryPosition | Returns: A newQueryPositionThe actual query is a string representation of the query that may contain
extra whitespace actualQuery, int The position of the cursor in the actual query, which is used to retrieve the
deepest position)Expression. The position will be adjusted to fit into the beautified version
of the queryCreates a map of the position of the cursor within each |
| public Expression | Returns: TheExpression located at the given position in the given queryThe actual query is the text version of the query that may contain extra
whitespace and different formatting than the trim down version generated by the parsed tree actualQuery, int The position in the actual query used to retrieve the position)ExpressionReturns the deepest |
| public JPQLGrammar | getGrammar()
Overrides org. Implements org. JPQLGrammar that defines how the JPQL query was parsed.
|
| public JPAVersion | getJPAVersion()
Overrides org. |
| public JPQLQueryBNF | getQueryBNF()
Implements org. Expression.
|
| public Expression | Returns: The expression representing the Java Persistence queryReturns the |
| public Expression | Returns: The expression used when the ending of the query is unknown or malformedReturns the |
| public boolean | Returns: true the query was parsed; false otherwiseDetermines whether a query was parsed. |
| public boolean | Returns: true if the query could not be parsed correctly
because it is either incomplete or malformedDetermines whether the query that got parsed had some malformed or unknown information. |
| protected boolean | isTolerant()
Overrides org. |
| protected void | parse(WordParser
The text to parse based on the current position of the cursor wordParser, boolean Determines whether the parsing system should be tolerant, meaning if it should
try to parse invalid or incomplete queries tolerant)Implements abstract org. WordParser.
|
| protected void | toParsedText(StringBuilder
The buffer used to append this writer, boolean Expression's string representationDetermines 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 identifiers actual)Implements abstract org. Expression, including its children,
if it has any.
|
| jpqlGrammar | back to summary |
|---|---|
| private JPQLGrammar jpqlGrammar The JPQL grammar that defines how to parse a JPQL query. | |
| queryBNFId | back to summary |
|---|---|
| private String queryBNFId By default, this is | |
| queryStatement | back to summary |
|---|---|
| private AbstractExpression queryStatement The tree representation of the query. | |
| tolerant | back to summary |
|---|---|
| private boolean tolerant Determines if the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries. | |
| unknownEndingStatement | back to summary |
|---|---|
| private AbstractExpression unknownEndingStatement If the expression could not be fully parsed, meaning some unknown text is trailing the query, this will contain it. | |
| JPQLExpression | back to summary |
|---|---|
| public JPQLExpression(CharSequence query, JPQLGrammar jpqlGrammar) Creates a new
| |
| JPQLExpression | back to summary |
|---|---|
| public JPQLExpression(CharSequence query, JPQLGrammar jpqlGrammar, boolean tolerant) Creates a new
| |
| JPQLExpression | back to summary |
|---|---|
| public JPQLExpression(CharSequence jpqlFragment, JPQLGrammar jpqlGrammar, String queryBNFId, boolean tolerant) Creates a new
| |
| JPQLExpression | back to summary |
|---|---|
| private JPQLExpression(JPQLGrammar jpqlGrammar, String queryBNFId, boolean tolerant) Creates a new
| |
| accept | back to summary |
|---|---|
| public void accept(ExpressionVisitor visitor) Implements org. Doc from org. Visits this
| |
| acceptChildren | back to summary |
|---|---|
| public void acceptChildren(ExpressionVisitor visitor) Implements org. Doc from org. Visits the children of this
This does not traverse the
| |
| addChildrenTo | back to summary |
|---|---|
| protected void addChildrenTo(Collection<Expression> children) Overrides org. Doc from org. Adds the children of this
| |
| addOrderedChildrenTo | back to summary |
|---|---|
| protected void addOrderedChildrenTo(List<Expression> children) Overrides org. Doc from org. Adds the children of this
| |
| buildPosition | back to summary |
|---|---|
| public QueryPosition buildPosition(String actualQuery, int position) Creates a map of the position of the cursor within each
| |
| getExpression | back to summary |
|---|---|
| public Expression getExpression(String actualQuery, int position) Returns the deepest
| |
| getGrammar | back to summary |
|---|---|
| public JPQLGrammar getGrammar() Overrides org. Implements org. Doc from org. Returns the
| |
| getJPAVersion | back to summary |
|---|---|
| public JPAVersion getJPAVersion() Overrides org. Doc from org. Returns the version of the Java Persistence to support.
| |
| getQueryBNF | back to summary |
|---|---|
| public JPQLQueryBNF getQueryBNF() Implements org. Doc from org. Returns the BNF of this
| |
| getQueryStatement | back to summary |
|---|---|
| public Expression getQueryStatement() Returns the
| |
| getUnknownEndingStatement | back to summary |
|---|---|
| public Expression getUnknownEndingStatement() Returns the
| |
| hasQueryStatement | back to summary |
|---|---|
| public boolean hasQueryStatement() Determines whether a query was parsed. The query may be incomplete but it started with one of the three clauses (SELECT, DELETE FROM, or UPDATE).
| |
| hasUnknownEndingStatement | back to summary |
|---|---|
| public boolean hasUnknownEndingStatement() Determines whether the query that got parsed had some malformed or unknown information.
| |
| isTolerant | back to summary |
|---|---|
| protected boolean isTolerant() Overrides org. Doc from org. Determines if the parser is in tolerant mode or is in fast mode. When the tolerant is turned on, it means the parser will attempt to parse incomplete or invalid queries.
| |
| parse | back to summary |
|---|---|
| protected void parse(WordParser wordParser, boolean tolerant) Implements abstract org. Doc from org. Parses the query by starting at the current position, which is part of the given
| |
| toParsedText | back to summary |
|---|---|
| protected void toParsedText(StringBuilder writer, boolean actual) Implements abstract org. Doc from org. Generates a string representation of this
| |