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

public abstract Class AbstractEncapsulatedExpression

extends AbstractExpression
Class Inheritance
Known Direct Subclasses
org.eclipse.persistence.jpa.jpql.parser.AbstractSingleEncapsulatedExpression, org.eclipse.persistence.jpa.jpql.parser.AbstractTripleEncapsulatedExpression, org.eclipse.persistence.jpa.jpql.parser.TreatExpression, org.eclipse.persistence.jpa.jpql.parser.AbstractDoubleEncapsulatedExpression
Imports
java.util.List, org.eclipse.persistence.jpa.jpql.WordParser

This expression handles parsing the identifier followed by an expression encapsulated within parenthesis.
BNF: expression ::= <identifier>(expression)
Author
Pascal Filion
Since
2.3
Version
2.5

Field Summary

Modifier and TypeField and Description
private boolean
hasLeftParenthesis

Flag used to determine if the closing parenthesis is present in the query.

private boolean
hasRightParenthesis

Flag used to determine if the opening parenthesis is present in the query.

private boolean
hasSpaceAfterIdentifier

Special flag used to separate the identifier with the encapsulated expression when the left parenthesis is missing.

private String
identifier

The actual identifier found in the string representation of the JPQL 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
protected
AbstractEncapsulatedExpression(AbstractExpression
The parent of this expression
parent
,
String
The JPQL identifier that starts this expression
identifier
)

Creates a new AbstractEncapsulatedExpression.

Method Summary

Modifier and TypeMethod and Description
protected final 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.
protected abstract void
addOrderedEncapsulatedExpressionTo(List<Expression>
The list used to store the string representation of the encapsulated Expression
children
)

Adds the Expressions representing the encapsulated Expression.

protected boolean
public final String

Returns:

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

Returns:

The JPQL identifier
getIdentifier
()

Returns the JPQL identifier of this expression.

public abstract boolean

Returns:

true if something was parsed; false otherwise
hasEncapsulatedExpression
()

Determines whether something was parsed after the left parenthesis.

public final boolean

Returns:

true if the open parenthesis was present in the string version of the query; false otherwise
hasLeftParenthesis
()

Determines whether the open parenthesis was parsed or not.

public final boolean

Returns:

true if the close parenthesis was present in the string version of the query; false otherwise
hasRightParenthesis
()

Determines whether the close parenthesis was parsed or not.

public boolean

Returns:

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

Determines whether a whitespace was parsed after the identifier rather than the left parenthesis.

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.
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 abstract 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
)

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

protected abstract void
removeEncapsulatedExpression()

Removes the encapsulated Expression that was parsed, it should not be part of this one.

protected boolean

Returns:

true if the right parenthesis should be owned by this expression if it is the next character to scan; false otherwise
shouldParseRightParenthesis
(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
)

Determines whether the right parenthesis should be parsed or not by this expression.

protected final 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.
protected abstract 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
)

Generates a string representation of the encapsulated Expression.

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

Field Detail

hasLeftParenthesisback to summary
private boolean hasLeftParenthesis

Flag used to determine if the closing parenthesis is present in the query.

hasRightParenthesisback to summary
private boolean hasRightParenthesis

Flag used to determine if the opening parenthesis is present in the query.

hasSpaceAfterIdentifierback to summary
private boolean hasSpaceAfterIdentifier

Special flag used to separate the identifier with the encapsulated expression when the left parenthesis is missing.

identifierback to summary
private String identifier

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

Constructor Detail

AbstractEncapsulatedExpressionback to summary
protected AbstractEncapsulatedExpression(AbstractExpression parent, String identifier)

Creates a new AbstractEncapsulatedExpression.

Parameters
parent:AbstractExpression

The parent of this expression

identifier:String

The JPQL identifier that starts this expression

Method Detail

addOrderedChildrenToback to summary
protected final 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
addOrderedEncapsulatedExpressionToback to summary
protected abstract void addOrderedEncapsulatedExpressionTo(List<Expression> children)

Adds the Expressions representing the encapsulated Expression.

Parameters
children:List<Expression>

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

areLogicalIdentifiersSupportedback to summary
protected boolean areLogicalIdentifiersSupported()
getActualIdentifierback to summary
public final 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 JPQL identifier that was actually parsed

getIdentifierback to summary
public final String getIdentifier()

Returns the JPQL identifier of this expression.

Returns:String

The JPQL identifier

hasEncapsulatedExpressionback to summary
public abstract boolean hasEncapsulatedExpression()

Determines whether something was parsed after the left parenthesis.

Returns:boolean

true if something was parsed; false otherwise

hasLeftParenthesisback to summary
public final boolean hasLeftParenthesis()

Determines whether the open parenthesis was parsed or not.

Returns:boolean

true if the open parenthesis was present in the string version of the query; false otherwise

hasRightParenthesisback to summary
public final boolean hasRightParenthesis()

Determines whether the close parenthesis was parsed or not.

Returns:boolean

true if the close parenthesis was present in the string version of the query; false otherwise

hasSpaceAfterIdentifierback to summary
public boolean hasSpaceAfterIdentifier()

Determines whether a whitespace was parsed after the identifier rather than the left parenthesis. This can happen in incomplete query of this form: ABS 4 + 5).

Returns:boolean

true if a whitespace was parsed after the identifier; 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
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
parseEncapsulatedExpressionback to summary
protected abstract void parseEncapsulatedExpression(WordParser wordParser, int whitespaceCount, boolean tolerant)

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

removeEncapsulatedExpressionback to summary
protected abstract void 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 ')'.

shouldParseRightParenthesisback to summary
protected boolean shouldParseRightParenthesis(WordParser wordParser, boolean tolerant)

Determines whether the right parenthesis should be parsed or not by this expression. There is a possible case where this expression should have optional left and right parenthesis. If there is no left parenthesis, then it would most likely mean the right parenthesis does not belong to this expression.

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

Returns:boolean

true if the right parenthesis should be owned by this expression if it is the next character to scan; false otherwise

toParsedTextback to summary
protected final 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
toParsedTextEncapsulatedExpressionback to summary
protected abstract void toParsedTextEncapsulatedExpression(StringBuilder writer, boolean actual)

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