Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.parser

public final Class HierarchicalQueryClause

extends AbstractExpression
Class Inheritance
Imports
java.util.Collection, .List, org.eclipse.persistence.jpa.jpql.WordParser

If a table contains hierarchical data, then rows can be selected in a hierarchical order using the hierarchical query clause.

START WITH specifies the root row(s) of the hierarchy.

CONNECT BY specifies the relationship between parent rows and child rows of the hierarchy.

BNF: hierarchical_query_clause ::= [start_with_clause] connectby_clause [order_siblings_by_clause]
Author
Pascal Filion
Since
2.5
Version
2.5
See Also
StartWithClause, ConnectByClause, OrderSiblingsByClause

Field Summary

Modifier and TypeField and Description
private AbstractExpression
connectByClause

The Expression that represents the CONNECT BY clause.

private boolean
hasSpaceAfterConnectByClause

Determines whether a whitespace was parsed after the CONNECT BY clause.

private boolean
hasSpaceAfterStartWithClause

Determines whether a whitespace was parsed after the START WITH clause.

private AbstractExpression
orderSiblingsByClause

The Expression that represents the ORDER SIBLINGS BY clause.

private AbstractExpression
startWithClause

The Expression that represents the START WITH clause.

Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
COMMADOTDOUBLE_QUOTELEFT_CURLY_BRACKETLEFT_PARENTHESISNOT_DEFINEDRIGHT_CURLY_BRACKETRIGHT_PARENTHESISSINGLE_QUOTESPACEUNDERSCORE

Constructor Summary

AccessConstructor and Description
public
HierarchicalQueryClause(AbstractExpression
The parent of this expression
parent
)

Creates a new HierarchicalQueryClause.

Method Summary

Modifier and TypeMethod and Description
public void
accept(ExpressionVisitor
The ExpressionVisitor to visit this object
visitor
)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Visits this Expression by the given visitor.
public void
acceptChildren(ExpressionVisitor
The visitor to visit the children of this object.
visitor
)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Visits the children of this Expression.
protected void
addChildrenTo(Collection<Expression>
The collection used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.
protected void
addOrderedChildrenTo(List<Expression>
The list used to store the string representation of this AbstractExpression
children
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.
public JPQLQueryBNF
findQueryBNF(Expression
The Expression that is a descendant of this one
expression
)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.findQueryBNF.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.
public Expression

Returns:

The expression representing the CONNECT BY clause
getConnectByClause
()

Returns the Expression representing the CONNECT BY clause.

public Expression

Returns:

The expression representing the ORDER SIBLINGS BY clause
getOrderSiblingsByClause
()

Returns the Expression representing the ORDER SIBLINGS BY clause.

public JPQLQueryBNF
public Expression

Returns:

The expression representing the START WITH clause
getStartWithClause
()

Returns the Expression representing the START WITH clause.

public boolean

Returns:

true if the query that got parsed had the CONNECT BY clause
hasConnectByClause
()

Determines whether the CONNECT BY clause is defined.

public boolean

Returns:

true if the query that got parsed had the ORDER SIBLINGS BY clause
hasOrderSiblingsByClause
()

Determines whether the ORDER SIBLINGS BY clause is defined.

public boolean

Returns:

true if there was a whitespace after the CONNECT BY clause and owned by this expression; false otherwise
hasSpaceAfterConnectByClause
()

Determines whether a whitespace was found after the CONNECT BY clause.

public boolean

Returns:

true if there was a whitespace after the START WITH clause and owned by this expression; false otherwise
hasSpaceAfterStartWithClause
()

Determines whether a whitespace was found after the START WITH clause.

public boolean

Returns:

true if the query that got parsed had the START WITH clause
hasStartWithClause
()

Determines whether the START WITH clause is defined.

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.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query by starting at the current position, which is part of the given WordParser.
protected void
toParsedText(StringBuilder
The buffer used to append this Expression's string representation
writer
,
boolean
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 identifiers
actual
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
acceptUnknownVisitoracceptUnknownVisitorbuildExpressionFromFallingBackbuildNullExpressionbuildStringExpressionbuildStringExpressionbuildUnknownExpressioncalculatePositionchildrenfindFallBackExpressionFactorygetExpressionFactorygetExpressionRegistrygetGrammargetIdentifierVersiongetJPAVersiongetLengthgetOffsetgetParentgetQueryBNFgetRootgetTexthandleAggregatehandleCollectionisAncestorisIdentifierisNullisParsingCompleteisTolerantisUnknownisVirtualorderedChildrenparseparseUsingExpressionFactorypopulatePositionrebuildActualTextrebuildParsedTextsetParentsetTextshouldParseWithFactoryFirstshouldSkipLiteraltoActualTexttoParsedTexttoString

Field Detail

connectByClauseback to summary
private AbstractExpression connectByClause

The Expression that represents the CONNECT BY clause.

hasSpaceAfterConnectByClauseback to summary
private boolean hasSpaceAfterConnectByClause

Determines whether a whitespace was parsed after the CONNECT BY clause.

hasSpaceAfterStartWithClauseback to summary
private boolean hasSpaceAfterStartWithClause

Determines whether a whitespace was parsed after the START WITH clause.

orderSiblingsByClauseback to summary
private AbstractExpression orderSiblingsByClause

The Expression that represents the ORDER SIBLINGS BY clause.

startWithClauseback to summary
private AbstractExpression startWithClause

The Expression that represents the START WITH clause.

Constructor Detail

HierarchicalQueryClauseback to summary
public HierarchicalQueryClause(AbstractExpression parent)

Creates a new HierarchicalQueryClause.

Parameters
parent:AbstractExpression

The parent of this expression

Method Detail

acceptback to summary
public void accept(ExpressionVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.accept.

Visits this Expression by the given visitor.

Parameters
visitor:ExpressionVisitor

The ExpressionVisitor to visit this object

Annotations
@Override
acceptChildrenback to summary
public void acceptChildren(ExpressionVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.acceptChildren.

Visits the children of this Expression. This method can be used to optimize traversing the children since a new list is not created every time children() is called.

This does not traverse the Expression sub-hierarchy, use a subclass of AbstractTraverseChildrenVisitor in order to traverse the entire sub-hierarchy.

Parameters
visitor:ExpressionVisitor

The visitor to visit the children of this object.

Annotations
@Override
addChildrenToback to summary
protected void addChildrenTo(Collection<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addChildrenTo.

Adds the children of this AbstractExpression to the given collection.

Parameters
children:Collection<Expression>

The collection used to store the children

Annotations
@Override
addOrderedChildrenToback to summary
protected void addOrderedChildrenTo(List<Expression> children)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.addOrderedChildrenTo.

Adds the children of this AbstractExpression to the given list.

Parameters
children:List<Expression>

The list used to store the string representation of this AbstractExpression

Annotations
@Override
findQueryBNFback to summary
public JPQLQueryBNF findQueryBNF(Expression expression)

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.findQueryBNF.

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.findQueryBNF.

Retrieves the JPQLQueryBNF that represents the fragment of this Expression that was used when parsing the given Expression.

Parameters
expression:Expression

The Expression that is a descendant of this one

Returns:JPQLQueryBNF

The JPQLQueryBNF that was used to parse the given expression

Annotations
@Override
getConnectByClauseback to summary
public Expression getConnectByClause()

Returns the Expression representing the CONNECT BY clause.

Returns:Expression

The expression representing the CONNECT BY clause

getOrderSiblingsByClauseback to summary
public Expression getOrderSiblingsByClause()

Returns the Expression representing the ORDER SIBLINGS BY clause.

Returns:Expression

The expression representing the ORDER SIBLINGS BY clause

getQueryBNFback to summary
public JPQLQueryBNF getQueryBNF()

Implements org.eclipse.persistence.jpa.jpql.parser.Expression.getQueryBNF.

Doc from org.eclipse.persistence.jpa.jpql.parser.Expression.getQueryBNF.

Returns the BNF of this Expression.

Returns:JPQLQueryBNF

The JPQLQueryBNF, which represents the grammar of this Expression

Annotations
@Override
getStartWithClauseback to summary
public Expression getStartWithClause()

Returns the Expression representing the START WITH clause.

Returns:Expression

The expression representing the START WITH clause

hasConnectByClauseback to summary
public boolean hasConnectByClause()

Determines whether the CONNECT BY clause is defined.

Returns:boolean

true if the query that got parsed had the CONNECT BY clause

hasOrderSiblingsByClauseback to summary
public boolean hasOrderSiblingsByClause()

Determines whether the ORDER SIBLINGS BY clause is defined.

Returns:boolean

true if the query that got parsed had the ORDER SIBLINGS BY clause

hasSpaceAfterConnectByClauseback to summary
public boolean hasSpaceAfterConnectByClause()

Determines whether a whitespace was found after the CONNECT BY clause. In some cases, the space is owned by a child of the hierarchical query clause.

Returns:boolean

true if there was a whitespace after the CONNECT BY clause and owned by this expression; false otherwise

hasSpaceAfterStartWithClauseback to summary
public boolean hasSpaceAfterStartWithClause()

Determines whether a whitespace was found after the START WITH clause. In some cases, the space is owned by a child of the hierarchical query clause.

Returns:boolean

true if there was a whitespace after the START WITH clause and owned by this expression; false otherwise

hasStartWithClauseback to summary
public boolean hasStartWithClause()

Determines whether the START WITH clause is defined.

Returns:boolean

true if the query that got parsed had the START WITH clause

parseback to summary
protected void parse(WordParser wordParser, boolean tolerant)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.parse.

Parses the query by starting at the current position, which is part of the given WordParser.

Parameters
wordParser:WordParser

The text to parse based on the current position of the cursor

tolerant:boolean

Determines whether the parsing system should be tolerant, meaning if it should try to parse invalid or incomplete queries

Annotations
@Override
toParsedTextback to summary
protected void toParsedText(StringBuilder writer, boolean actual)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.toParsedText.

Generates a string representation of this Expression, including its children, if it has any.

Parameters
writer:StringBuilder

The buffer used to append this Expression's string representation

actual:boolean

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 identifiers

Annotations
@Override