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

public abstract Class AbstractTripleEncapsulatedExpression

extends AbstractEncapsulatedExpression
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.parser.LocateExpression, org.eclipse.persistence.jpa.jpql.parser.SubstringExpression
Imports
java.util.ArrayList, .Collection, .List, org.eclipse.persistence.jpa.jpql.WordParser

This Expression takes care of parsing an expression that encapsulates three expressions separated by a comma.
BNF: expression ::= <identifier>(first_expression, second_expression, third_expression)
Author
Pascal Filion
Since
2.3
Version
2.5.1
See Also
LocateExpression, SubstringExpression

Field Summary

Modifier and TypeField and Description
private AbstractExpression
firstExpression

The Expression that represents the first expression.

private boolean
hasFirstComma

Determines whether the comma separating the first and second expression was parsed.

private boolean
hasSecondComma

Determines whether the comma separating the first and second expression was parsed.

private boolean
hasSpaceAfterFirstComma

Determines whether a whitespace is following the comma.

private boolean
hasSpaceAfterSecondComma

Determines whether a whitespace is following the comma.

protected int
parameterIndex

Determines which child expression is been currently parsed.

private AbstractExpression
secondExpression

The Expression that represents the second expression.

private AbstractExpression
thirdExpression

The Expression that represents the first expression.

Constructor Summary

AccessConstructor and Description
protected
AbstractTripleEncapsulatedExpression(AbstractExpression
The parent of this expression
parent
,
String
The JPQL identifier that starts this expression
identifier
)

Creates a new AbstractTripleEncapsulatedExpression.

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
addOrderedEncapsulatedExpressionTo(List<Expression>
The list used to store the string representation of the encapsulated Expression
children
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.addOrderedEncapsulatedExpressionTo.

Adds the Expressions representing the encapsulated Expression.
public final CollectionExpression

Returns:

The first, second and third expressions represented by a temporary collection
buildCollectionExpression
()

Creates a new CollectionExpression that will wrap the first, second and third expressions.

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 Expression

Returns:

The expression that was parsed representing the first expression
getFirstExpression
()

Returns the Expression that represents the first expression.

public abstract String

Returns:

The ID of the JPQLQueryBNF to be used to parse one of the encapsulated expression
getParameterQueryBNFId
(int
The position of the encapsulated Expression that needs to be parsed within the parenthesis, which starts at position 0
index
)

Returns the unique identifier of the JPQLQueryBNF to be used to parse one of the encapsulated expression at the given position.

public final Expression

Returns:

The expression that was parsed representing the second expression
getSecondExpression
()

Returns the Expression that represents the second expression.

public final Expression

Returns:

The expression that was parsed representing the first expression
getThirdExpression
()

Returns the Expression that represents the first expression.

public boolean
hasEncapsulatedExpression()

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.hasEncapsulatedExpression.

Determines whether something was parsed after the left parenthesis.
public final boolean

Returns:

true if a comma was parsed after the first expression; false otherwise
hasFirstComma
()

Determines whether the comma was parsed after the first expression.

public final boolean

Returns:

true if the first expression was parsed; false if it was not parsed
hasFirstExpression
()

Determines whether the first expression of the query was parsed.

public final boolean

Returns:

true if a comma was parsed after the second expression; false otherwise
hasSecondComma
()

Determines whether the comma was parsed after the second expression.

public final boolean

Returns:

true if the second expression was parsed; false if it was not parsed
hasSecondExpression
()

Determines whether the second expression of the query was parsed.

public final boolean

Returns:

true if there was a whitespace after the first comma; false otherwise
hasSpaceAfterFirstComma
()

Determines whether a whitespace was parsed after the first comma.

public final boolean

Returns:

true if there was a whitespace after the second comma; false otherwise
hasSpaceAfterSecondComma
()

Determines whether a whitespace was parsed after the second comma.

public final boolean

Returns:

true if the third expression was parsed; false if it was not parsed
hasThirdExpression
()

Determines whether the third expression of the query was parsed.

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.AbstractEncapsulatedExpression.isParsingComplete.

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

Returns:

true if the third expression can either be present or not in a valid query; false if it's mandatory
isThirdExpressionOptional
()

Determines whether the third expression is an optional expression, which means a valid query can have it or not.

protected void
parseEncapsulatedExpression(WordParser
The text to parse based on the current position of the cursor
wordParser
,
int
The number of whitespace characters that were parsed after '('
whitespaceCount
,
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.AbstractEncapsulatedExpression.parseEncapsulatedExpression.

Parses the encapsulated expression by starting at the current position, which is part of the given WordParser.
protected void
removeEncapsulatedExpression()

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.removeEncapsulatedExpression.

Removes the encapsulated Expression that was parsed, it should not be part of this one.
protected final void
toParsedTextEncapsulatedExpression(StringBuilder
The buffer used to append the encapsulated Expression's string representation
writer
,
boolean
Determines whether to include any characters that are considered virtual, i.e. that was parsed when the query is incomplete and is needed for functionality like content assist
actual
)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.toParsedTextEncapsulatedExpression.

Generates a string representation of the encapsulated Expression.
Inherited from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression:
addOrderedChildrenToareLogicalIdentifiersSupportedgetActualIdentifiergetIdentifierhasLeftParenthesishasRightParenthesishasSpaceAfterIdentifierparseshouldParseRightParenthesistoParsedText

Field Detail

firstExpressionback to summary
private AbstractExpression firstExpression

The Expression that represents the first expression.

hasFirstCommaback to summary
private boolean hasFirstComma

Determines whether the comma separating the first and second expression was parsed.

hasSecondCommaback to summary
private boolean hasSecondComma

Determines whether the comma separating the first and second expression was parsed.

hasSpaceAfterFirstCommaback to summary
private boolean hasSpaceAfterFirstComma

Determines whether a whitespace is following the comma.

hasSpaceAfterSecondCommaback to summary
private boolean hasSpaceAfterSecondComma

Determines whether a whitespace is following the comma.

parameterIndexback to summary
protected int parameterIndex

Determines which child expression is been currently parsed.

secondExpressionback to summary
private AbstractExpression secondExpression

The Expression that represents the second expression.

thirdExpressionback to summary
private AbstractExpression thirdExpression

The Expression that represents the first expression.

Constructor Detail

AbstractTripleEncapsulatedExpressionback to summary
protected AbstractTripleEncapsulatedExpression(AbstractExpression parent, String identifier)

Creates a new AbstractTripleEncapsulatedExpression.

Parameters
parent:AbstractExpression

The parent of this expression

identifier:String

The JPQL identifier that starts 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
addOrderedEncapsulatedExpressionToback to summary
protected void addOrderedEncapsulatedExpressionTo(List<Expression> children)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.addOrderedEncapsulatedExpressionTo.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.addOrderedEncapsulatedExpressionTo.

Adds the Expressions representing the encapsulated Expression.

Parameters
children:List<Expression>

The list used to store the string representation of the encapsulated Expression

Annotations
@Override
buildCollectionExpressionback to summary
public final CollectionExpression buildCollectionExpression()

Creates a new CollectionExpression that will wrap the first, second and third expressions.

Returns:CollectionExpression

The first, second and third expressions 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
getFirstExpressionback to summary
public final Expression getFirstExpression()

Returns the Expression that represents the first expression.

Returns:Expression

The expression that was parsed representing the first expression

getParameterQueryBNFIdback to summary
public abstract String getParameterQueryBNFId(int index)

Returns the unique identifier of the JPQLQueryBNF to be used to parse one of the encapsulated expression at the given position.

Parameters
index:int

The position of the encapsulated Expression that needs to be parsed within the parenthesis, which starts at position 0

Returns:String

The ID of the JPQLQueryBNF to be used to parse one of the encapsulated expression

getSecondExpressionback to summary
public final Expression getSecondExpression()

Returns the Expression that represents the second expression.

Returns:Expression

The expression that was parsed representing the second expression

getThirdExpressionback to summary
public final Expression getThirdExpression()

Returns the Expression that represents the first expression.

Returns:Expression

The expression that was parsed representing the first expression

hasEncapsulatedExpressionback to summary
public boolean hasEncapsulatedExpression()

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.hasEncapsulatedExpression.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.hasEncapsulatedExpression.

Determines whether something was parsed after the left parenthesis.

Returns:boolean

true if something was parsed; false otherwise

Annotations
@Override
hasFirstCommaback to summary
public final boolean hasFirstComma()

Determines whether the comma was parsed after the first expression.

Returns:boolean

true if a comma was parsed after the first expression; false otherwise

hasFirstExpressionback to summary
public final boolean hasFirstExpression()

Determines whether the first expression of the query was parsed.

Returns:boolean

true if the first expression was parsed; false if it was not parsed

hasSecondCommaback to summary
public final boolean hasSecondComma()

Determines whether the comma was parsed after the second expression.

Returns:boolean

true if a comma was parsed after the second expression; false otherwise

hasSecondExpressionback to summary
public final boolean hasSecondExpression()

Determines whether the second expression of the query was parsed.

Returns:boolean

true if the second expression was parsed; false if it was not parsed

hasSpaceAfterFirstCommaback to summary
public final boolean hasSpaceAfterFirstComma()

Determines whether a whitespace was parsed after the first comma.

Returns:boolean

true if there was a whitespace after the first comma; false otherwise

hasSpaceAfterSecondCommaback to summary
public final boolean hasSpaceAfterSecondComma()

Determines whether a whitespace was parsed after the second comma.

Returns:boolean

true if there was a whitespace after the second comma; false otherwise

hasThirdExpressionback to summary
public final boolean hasThirdExpression()

Determines whether the third expression of the query was parsed.

Returns:boolean

true if the third expression was parsed; false if it was not parsed

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

Overrides org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.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
isThirdExpressionOptionalback to summary
protected abstract boolean isThirdExpressionOptional()

Determines whether the third expression is an optional expression, which means a valid query can have it or not.

Returns:boolean

true if the third expression can either be present or not in a valid query; false if it's mandatory

parseEncapsulatedExpressionback to summary
protected void parseEncapsulatedExpression(WordParser wordParser, int whitespaceCount, boolean tolerant)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.parseEncapsulatedExpression.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.parseEncapsulatedExpression.

Parses the encapsulated expression 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

whitespaceCount:int

The number of whitespace characters that were parsed after '('

tolerant:boolean

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

Annotations
@Override
removeEncapsulatedExpressionback to summary
protected void removeEncapsulatedExpression()

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.removeEncapsulatedExpression.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.removeEncapsulatedExpression.

Removes the encapsulated Expression that was parsed, it should not be part of this one. This happens when the parsed information does not have both '(' and ')'.

Annotations
@Override
toParsedTextEncapsulatedExpressionback to summary
protected final void toParsedTextEncapsulatedExpression(StringBuilder writer, boolean actual)

Implements abstract org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.toParsedTextEncapsulatedExpression.

Doc from org.eclipse.persistence.jpa.jpql.parser.AbstractEncapsulatedExpression.toParsedTextEncapsulatedExpression.

Generates a string representation of the encapsulated Expression.

Parameters
writer:StringBuilder

The buffer used to append the encapsulated Expression's string representation

actual:boolean

Determines whether to include any characters that are considered virtual, i.e. that was parsed when the query is incomplete and is needed for functionality like content assist

Annotations
@Override