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

public final Class UnionClause

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

The UNION clause allows the results of two queries to be combined.
BNF: union_clause ::= { UNION | INTERSECT | EXCEPT } [ALL] subquery
Author
James Sutherland
Since
2.4
Version
2.5

Field Summary

Modifier and TypeField and Description
private String
actualIdentifier

The actual identifier found in the string representation of the JPQL query.

private String
allIdentifier

The actual All identifier found in the string representation of the JPQL query.

private boolean
hasSpaceAfterAll

Determines whether a whitespace was parsed after ALL.

private boolean
hasSpaceAfterIdentifier

Determines whether a whitespace was parsed after UNION.

private AbstractExpression
query

The Expression representing the unioned query.

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
UnionClause(AbstractExpression
The parent of this expression
parent
,
String
Either UNION, INTERSECT or EXCEPT
identifier
)

Creates a new UnionClause.

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 String

Returns:

The ALL identifier that was actually parsed
getActualAll
()

Returns the actual ALL found in the string representation of the JPQL query, which has the actual case that was used.

public String

Returns:

The identifier that was actually parsed
getActualIdentifier
()

Returns the actual identifier found in the string representation of the JPQL query, which has the actual case that was used.

public String

Returns:

Either "UNION", "INTERSECT", "EXCEPT"
getIdentifier
()

Returns the union identifier.

public Expression

Returns:

The Expression representing the subquery
getQuery
()

Returns the Expression representing the unioned query.

public JPQLQueryBNF
public boolean

Returns:

true if ALL was parsed; false otherwise
hasAll
()

Determines whether ALL was parsed.

public boolean

Returns:

true the query was parsed; false otherwise
hasQuery
()

Determines whether the query was parsed.

public boolean

Returns:

true if a whitespace was parsed after ALL; false otherwise
hasSpaceAfterAll
()

Determines whether a whitespace was parsed after ALL.

public boolean

Returns:

true if a whitespace was parsed after the identifier; false otherwise
hasSpaceAfterIdentifier
()

Determines whether a whitespace was parsed after the identifier.

public boolean

Returns:

true if the identifier is EXCEPT; false otherwise
isExcept
()

Determines whether this UnionClause uses the EXCEPT identifier.

public boolean

Returns:

true if the identifier is INTERSECT; false otherwise
isIntersect
()

Determines whether this UnionClause uses the INTERSECT identifier.

protected boolean
isParsingComplete(WordParser
The text to parse based on the current position of the cursor
wordParser
,
String
The word that was retrieved from the given text, which is the first word in the text
word
,
Expression
The Expression that has already been parsed
expression
)

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

Determines whether the parsing is complete based on what is left in the given text.
public boolean

Returns:

true if the identifier is UNION; false otherwise
isUnion
()

Determines whether this UnionClause uses the UNION identifier.

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 String

Returns:

Either UNION, INTERSECT or EXCEPT
parseIdentifier
()

Parses the JPQL identifier identifier the type of union.

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:
acceptUnknownVisitoracceptUnknownVisitorbuildExpressionFromFallingBackbuildNullExpressionbuildStringExpressionbuildStringExpressionbuildUnknownExpressioncalculatePositionchildrenfindFallBackExpressionFactorygetExpressionFactorygetExpressionRegistrygetGrammargetIdentifierVersiongetJPAVersiongetLengthgetOffsetgetParentgetQueryBNFgetRootgetTexthandleAggregatehandleCollectionisAncestorisIdentifierisNullisTolerantisUnknownisVirtualorderedChildrenparseparseUsingExpressionFactorypopulatePositionrebuildActualTextrebuildParsedTextsetParentsetTextshouldParseWithFactoryFirstshouldSkipLiteraltoActualTexttoParsedTexttoString

Field Detail

actualIdentifierback to summary
private String actualIdentifier

The actual identifier found in the string representation of the JPQL query.

allIdentifierback to summary
private String allIdentifier

The actual All identifier found in the string representation of the JPQL query.

hasSpaceAfterAllback to summary
private boolean hasSpaceAfterAll

Determines whether a whitespace was parsed after ALL.

hasSpaceAfterIdentifierback to summary
private boolean hasSpaceAfterIdentifier

Determines whether a whitespace was parsed after UNION.

queryback to summary
private AbstractExpression query

The Expression representing the unioned query.

Constructor Detail

UnionClauseback to summary
public UnionClause(AbstractExpression parent, String identifier)

Creates a new UnionClause.

Parameters
parent:AbstractExpression

The parent of this expression

identifier:String

Either UNION, INTERSECT or EXCEPT

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
getActualAllback to summary
public String getActualAll()

Returns the actual ALL found in the string representation of the JPQL query, which has the actual case that was used.

Returns:String

The ALL identifier that was actually parsed

getActualIdentifierback to summary
public String getActualIdentifier()

Returns the actual identifier found in the string representation of the JPQL query, which has the actual case that was used.

Returns:String

The identifier that was actually parsed

getIdentifierback to summary
public String getIdentifier()

Returns the union identifier.

Returns:String

Either "UNION", "INTERSECT", "EXCEPT"

getQueryback to summary
public Expression getQuery()

Returns the Expression representing the unioned query.

Returns:Expression

The Expression representing the subquery

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
hasAllback to summary
public boolean hasAll()

Determines whether ALL was parsed.

Returns:boolean

true if ALL was parsed; false otherwise

hasQueryback to summary
public boolean hasQuery()

Determines whether the query was parsed.

Returns:boolean

true the query was parsed; false otherwise

hasSpaceAfterAllback to summary
public boolean hasSpaceAfterAll()

Determines whether a whitespace was parsed after ALL.

Returns:boolean

true if a whitespace was parsed after ALL; false otherwise

hasSpaceAfterIdentifierback to summary
public boolean hasSpaceAfterIdentifier()

Determines whether a whitespace was parsed after the identifier.

Returns:boolean

true if a whitespace was parsed after the identifier; false otherwise

isExceptback to summary
public boolean isExcept()

Determines whether this UnionClause uses the EXCEPT identifier.

Returns:boolean

true if the identifier is EXCEPT; false otherwise

isIntersectback to summary
public boolean isIntersect()

Determines whether this UnionClause uses the INTERSECT identifier.

Returns:boolean

true if the identifier is INTERSECT; false otherwise

isParsingCompleteback to summary
protected boolean isParsingComplete(WordParser wordParser, String word, Expression expression)

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

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

Determines whether the parsing is complete based on what is left in the given text. The text is never empty.

Parameters
wordParser:WordParser

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

word:String

The word that was retrieved from the given text, which is the first word in the text

expression:Expression

The Expression that has already been parsed

Returns:boolean

true if the text no longer can't be parsed by the current expression; false if more can be parsed

Annotations
@Override
isUnionback to summary
public boolean isUnion()

Determines whether this UnionClause uses the UNION identifier.

Returns:boolean

true if the identifier is UNION; false otherwise

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
parseIdentifierback to summary
protected String parseIdentifier()

Parses the JPQL identifier identifier the type of union.

Returns:String

Either UNION, INTERSECT or EXCEPT

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