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

public final Class CollectionExpression

extends AbstractExpression
Class Inheritance
Annotations
@SuppressWarnings:nls
Imports
java.util.Collection, .List, org.eclipse.persistence.jpa.jpql.WordParser

A CollectionExpression wraps many expression which they are separated by spaces and/or commas.
BNF: expression ::= child_item {, child_item }*

or
BNF: expression ::= child_item { child_item }*
Author
Pascal Filion
Since
2.3
Version
2.5

Field Summary

Modifier and TypeField and Description
private List<AbstractExpression>
children

Hides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.children.

The Expressions that forms a collection within another expression.
private List<Boolean>
commas

The list of flags used to determine where to separate two child Expressions with a comma or with a space only.

private List<Boolean>
spaces

Flag used to determine when a space is required after a comma.

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
CollectionExpression(AbstractExpression
The parent of this expression
parent
,
List<AbstractExpression>
The list of children that are regrouped together
children
,
List<Boolean>
The list of flags used to determine when to add a comma after an Expression
commas
,
List<Boolean>
The list of flags used to determine when to add a space after an Expression
spaces
)

Creates a new CollectionExpression.

public
CollectionExpression(AbstractExpression
The parent of this expression
parent
,
List<AbstractExpression>
The list of children that are regrouped together
children
,
List<Boolean>
The list of flags used to determine when to add a comma after an Expression
commas
,
List<Boolean>
The list of flags used to determine when to add a space after an Expression
spaces
,
boolean
Flag used to determine if this expression is temporarily used, which means the children will not be parented to this object
temporary
)

Creates a new CollectionExpression.

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
accept(int
The index of the child to visit
index
,
ExpressionVisitor
The ExpressionVisitor to visit a specific child
visitor
)

Visits the child Expression at the given position 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 int

Returns:

The total count of expressions aggregated with spaces and/or commas
childrenSize
()

Returns the count of child expressions.

public boolean

Returns:

true if the string representation of this CollectionExpression ends with a comma (the ending space is not checked)
endsWithComma
()

Determines whether this CollectionExpression ends with a comma, which means the last Expression is a "null" expression.

public boolean

Returns:

true if the string representation of this CollectionExpression ends with a space (the ending comma is not checked)
endsWithSpace
()

Determines whether this CollectionExpression ends with a space, which means the last Expression is a "null" expression.

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 child Expression at the given position
getChild
(int
The position of the child Expression to retrieve
index
)

Retrieves the child Expression at the given position.

private AbstractExpression
getChildInternal(int index)

public JPQLQueryBNF
public boolean

Returns:

true if a comma is following the child Expression at the given index; false otherwise
hasComma
(int
The index of the child Expression to verify if there is a comma following it
index
)

Determines whether a comma was parsed at the given position.

public boolean

Returns:

true if a space is following the child Expression at the given index; false otherwise
hasSpace
(int
The index of the child Expression to verify if there is a space following it, which could be after a comma, if one was parsed
index
)

Determines whether a space was parsed at the given position.

public int

Returns:

The index in the collection of the given Expression or -1 if it is not a child
indexOf
(Expression
The Expression that might be a child of this expression
expression
)

Retrieves the index of the given Expression.

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.
public String

Returns:

The string representation of this Expression
toActualText
(int
The index used to determine when to create the string representation, which is exclusive
endIndex
)

Returns a string representation of this Expression and its children.

public String

Returns:

The string representation of this Expression
toParsedText
(int
The index used to determine when to create the string representation, which is exclusive
endIndex
)

Generates a string representation of this CollectionExpression.

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.
private void
toParsedText(StringBuilder writer, int endIndex, boolean actual)

private void
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractExpression:
acceptUnknownVisitoracceptUnknownVisitorbuildExpressionFromFallingBackbuildNullExpressionbuildStringExpressionbuildStringExpressionbuildUnknownExpressioncalculatePositionchildrenfindFallBackExpressionFactorygetExpressionFactorygetExpressionRegistrygetGrammargetIdentifierVersiongetJPAVersiongetLengthgetOffsetgetParentgetQueryBNFgetRootgetTexthandleAggregatehandleCollectionisAncestorisIdentifierisNullisParsingCompleteisTolerantisUnknownisVirtualorderedChildrenparseparseUsingExpressionFactorypopulatePositionrebuildActualTextrebuildParsedTextsetParentsetTextshouldParseWithFactoryFirstshouldSkipLiteraltoActualTexttoParsedTexttoString

Field Detail

childrenback to summary
private List<AbstractExpression> children

Hides org.eclipse.persistence.jpa.jpql.parser.AbstractExpression.children.

The Expressions that forms a collection within another expression.

commasback to summary
private List<Boolean> commas

The list of flags used to determine where to separate two child Expressions with a comma or with a space only.

spacesback to summary
private List<Boolean> spaces

Flag used to determine when a space is required after a comma.

Constructor Detail

CollectionExpressionback to summary
public CollectionExpression(AbstractExpression parent, List<AbstractExpression> children, List<Boolean> commas, List<Boolean> spaces)

Creates a new CollectionExpression.

Parameters
parent:AbstractExpression

The parent of this expression

children:List<AbstractExpression>

The list of children that are regrouped together

commas:List<Boolean>

The list of flags used to determine when to add a comma after an Expression

spaces:List<Boolean>

The list of flags used to determine when to add a space after an Expression

CollectionExpressionback to summary
public CollectionExpression(AbstractExpression parent, List<AbstractExpression> children, List<Boolean> commas, List<Boolean> spaces, boolean temporary)

Creates a new CollectionExpression.

Parameters
parent:AbstractExpression

The parent of this expression

children:List<AbstractExpression>

The list of children that are regrouped together

commas:List<Boolean>

The list of flags used to determine when to add a comma after an Expression

spaces:List<Boolean>

The list of flags used to determine when to add a space after an Expression

temporary:boolean

Flag used to determine if this expression is temporarily used, which means the children will not be parented to this object

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
acceptback to summary
public void accept(int index, ExpressionVisitor visitor)

Visits the child Expression at the given position by the given visitor.

Parameters
index:int

The index of the child to visit

visitor:ExpressionVisitor

The ExpressionVisitor to visit a specific child

Since
2.4
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
childrenSizeback to summary
public int childrenSize()

Returns the count of child expressions.

Returns:int

The total count of expressions aggregated with spaces and/or commas

endsWithCommaback to summary
public boolean endsWithComma()

Determines whether this CollectionExpression ends with a comma, which means the last Expression is a "null" expression.

Returns:boolean

true if the string representation of this CollectionExpression ends with a comma (the ending space is not checked)

endsWithSpaceback to summary
public boolean endsWithSpace()

Determines whether this CollectionExpression ends with a space, which means the last Expression is a "null" expression.

Returns:boolean

true if the string representation of this CollectionExpression ends with a space (the ending comma is not checked)

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
getChildback to summary
public Expression getChild(int index)

Retrieves the child Expression at the given position.

Parameters
index:int

The position of the child Expression to retrieve

Returns:Expression

The child Expression at the given position

getChildInternalback to summary
private AbstractExpression getChildInternal(int index)
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
hasCommaback to summary
public boolean hasComma(int index)

Determines whether a comma was parsed at the given position. The index is the position of the comma that is following the child at the same position.

Parameters
index:int

The index of the child Expression to verify if there is a comma following it

Returns:boolean

true if a comma is following the child Expression at the given index; false otherwise

hasSpaceback to summary
public boolean hasSpace(int index)

Determines whether a space was parsed at the given position. The index is the position of the space that is following the child at the same position, which is after a comma, if one was also parsed at that location.

Parameters
index:int

The index of the child Expression to verify if there is a space following it, which could be after a comma, if one was parsed

Returns:boolean

true if a space is following the child Expression at the given index; false otherwise

indexOfback to summary
public int indexOf(Expression expression)

Retrieves the index of the given Expression.

Parameters
expression:Expression

The Expression that might be a child of this expression

Returns:int

The index in the collection of the given Expression or -1 if it is not a child

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
toActualTextback to summary
public String toActualText(int endIndex)

Returns a string representation of this Expression 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#toParsedText() would return "SELECT e".

Parameters
endIndex:int

The index used to determine when to create the string representation, which is exclusive

Returns:String

The string representation of this Expression

toParsedTextback to summary
public String toParsedText(int endIndex)

Generates a string representation of this CollectionExpression.

Parameters
endIndex:int

The index used to determine when to create the string representation, which is exclusive

Returns:String

The string representation of this Expression

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
toParsedTextback to summary
private void toParsedText(StringBuilder writer, int endIndex, boolean actual)
updateBackpointersback to summary
private void updateBackpointers()