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

public abstract Class AbstractSelectClause

extends AbstractExpression
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.parser.SelectClause, org.eclipse.persistence.jpa.jpql.parser.SimpleSelectClause
Imports
java.util.ArrayList, .Collection, .List, org.eclipse.persistence.jpa.jpql.WordParser

The SELECT clause denotes the query result. More than one value may be returned from the SELECT clause of a query. The SELECT clause may contain one or more of the following elements: a single range variable or identification variable that ranges over an entity abstract schema type, a single-valued path expression, an aggregate select expression, a constructor expression.

The DISTINCT keyword is used to specify that duplicate values must be eliminated from the query result. If DISTINCT is not specified, duplicate values are not eliminated. Stand-alone identification variables in the SELECT clause may optionally be qualified by the OBJECT operator. The SELECT clause must not use the OBJECT operator to qualify path expressions.

Author
Pascal Filion
Since
2.3
Version
2.5
See Also
SelectClause, SimpleSelectClause

Field Summary

Modifier and TypeField and Description
private String
distinctIdentifier

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

private boolean
hasSpaceAfterDistinct

Determines whether a whitespace was parsed after the DISTINCT.

private boolean
hasSpaceAfterSelect

Determines whether a whitespace was parsed after the SELECT.

private String
identifier

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

private AbstractExpression
selectExpression

The actual expression of this select 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
protected
AbstractSelectClause(AbstractExpression
The parent of this expression
parent
)

Creates a new SelectClause.

Method Summary

Modifier and TypeMethod and Description
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 CollectionExpression

Returns:

The single select item represented by a temporary collection
buildCollectionExpression
()

Creates a new CollectionExpression that will wrap the single select item.

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 final String

Returns:

The DISTINCT identifier that was actually parsed, or an empty string if it was not parsed
getActualDistinctIdentifier
()

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

public final String

Returns:

The SELECT identifier that was actually parsed
getActualIdentifier
()

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

public final Expression

Returns:

The expression representing the select items
getSelectExpression
()

Returns the Expression representing the select items.

public abstract String

Returns:

The ID of the query BNF for the list of select items to parse
getSelectItemQueryBNFId
()

Returns the unique identifier of the JPQLQueryBNF for the list of select items to parse.

public final boolean

Returns:

true if the identifier DISTINCT was parsed; false otherwise
hasDistinct
()

Determines whether the identifier DISTINCT was parsed or not.

public final boolean

Returns:

true the list of select items was parsed; false otherwise
hasSelectExpression
()

Determines whether the list of select items was parsed.

public final boolean

Returns:

true if there was a whitespace after DISTINCT; false otherwise
hasSpaceAfterDistinct
()

Determines whether a whitespace was parsed after DISTINCT.

public final boolean

Returns:

true if there was a whitespace after SELECT; false otherwise
hasSpaceAfterSelect
()

Determines whether a whitespace was parsed after SELECT.

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 boolean
shouldSkipLiteral(AbstractExpression
The Expression that has just been parsed or null
expression
)

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

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.
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:
acceptUnknownVisitoracceptUnknownVisitorbuildExpressionFromFallingBackbuildNullExpressionbuildStringExpressionbuildStringExpressionbuildUnknownExpressioncalculatePositionchildrenfindFallBackExpressionFactorygetExpressionFactorygetExpressionRegistrygetGrammargetIdentifierVersiongetJPAVersiongetLengthgetOffsetgetParentgetQueryBNFgetRootgetTexthandleAggregatehandleCollectionisAncestorisIdentifierisNullisParsingCompleteisTolerantisUnknownisVirtualorderedChildrenparseparseUsingExpressionFactorypopulatePositionrebuildActualTextrebuildParsedTextsetParentsetTextshouldParseWithFactoryFirsttoActualTexttoParsedTexttoString

Field Detail

distinctIdentifierback to summary
private String distinctIdentifier

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

hasSpaceAfterDistinctback to summary
private boolean hasSpaceAfterDistinct

Determines whether a whitespace was parsed after the DISTINCT.

hasSpaceAfterSelectback to summary
private boolean hasSpaceAfterSelect

Determines whether a whitespace was parsed after the SELECT.

identifierback to summary
private String identifier

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

selectExpressionback to summary
private AbstractExpression selectExpression

The actual expression of this select clause.

Constructor Detail

AbstractSelectClauseback to summary
protected AbstractSelectClause(AbstractExpression parent)

Creates a new SelectClause.

Parameters
parent:AbstractExpression

The parent of this expression

Method Detail

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
buildCollectionExpressionback to summary
public CollectionExpression buildCollectionExpression()

Creates a new CollectionExpression that will wrap the single select item.

Returns:CollectionExpression

The single select item represented by a temporary collection

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
getActualDistinctIdentifierback to summary
public final String getActualDistinctIdentifier()

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

Returns:String

The DISTINCT identifier that was actually parsed, or an empty string if it was not parsed

Since
2.4
getActualIdentifierback to summary
public final String getActualIdentifier()

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

Returns:String

The SELECT identifier that was actually parsed

getSelectExpressionback to summary
public final Expression getSelectExpression()

Returns the Expression representing the select items.

Returns:Expression

The expression representing the select items

getSelectItemQueryBNFIdback to summary
public abstract String getSelectItemQueryBNFId()

Returns the unique identifier of the JPQLQueryBNF for the list of select items to parse.

Returns:String

The ID of the query BNF for the list of select items to parse

hasDistinctback to summary
public final boolean hasDistinct()

Determines whether the identifier DISTINCT was parsed or not.

Returns:boolean

true if the identifier DISTINCT was parsed; false otherwise

hasSelectExpressionback to summary
public final boolean hasSelectExpression()

Determines whether the list of select items was parsed.

Returns:boolean

true the list of select items was parsed; false otherwise

hasSpaceAfterDistinctback to summary
public final boolean hasSpaceAfterDistinct()

Determines whether a whitespace was parsed after DISTINCT.

Returns:boolean

true if there was a whitespace after DISTINCT; false otherwise

hasSpaceAfterSelectback to summary
public final boolean hasSpaceAfterSelect()

Determines whether a whitespace was parsed after SELECT.

Returns:boolean

true if there was a whitespace after SELECT; 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
shouldSkipLiteralback to summary
protected boolean shouldSkipLiteral(AbstractExpression expression)

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

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

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. Example: BETWEEN 10 20, when parsing 20, it should not be parsed as part of the lower bound expression.

Parameters
expression:AbstractExpression

The Expression that has just been parsed or null

Returns:boolean

true

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