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

public final Class TreatExpression

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

Returns an expression that allows to treat its base as if it were a subclass of the class returned by the base.

New to EclipseLink 2.1.

BNF: join_treat ::= TREAT(collection_valued_path_expression AS entity_type_literal)

Example: SELECT e FROM Employee e JOIN TREAT(e.projects AS LargeProject) lp WHERE lp.budget = value

Author
Pascal Filion
Since
2.3
Version
2.5.1

Field Summary

Modifier and TypeField and Description
private String
asIdentifier

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

private AbstractExpression
collectionValuedPathExpression

The Expression that represents the collection-valued path expression.

private AbstractExpression
entityType

The entity type used to downcast the type of the elements in the collection.

private boolean
hasSpaceAfterAs

Determines whether a whitespace was parsed after AS.

private boolean
hasSpaceAfterCollectionValuedPathExpression

Determines whether a whitespace was parsed after the collection-valued path expression.

private int
parameterIndex

Determines which child expression is been currently parsed.

Constructor Summary

AccessConstructor and Description
public
TreatExpression(AbstractExpression
The parent of this expression
parent
)

Creates a new TreatExpression.

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
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 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 AS identifier that was actually parsed, or an empty string if it was not parsed
getActualAsIdentifier
()

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

public Expression

Returns:

The expression that represents the collection-valued path expression
getCollectionValuedPathExpression
()

Returns the Expression that represents the collection-valued path expression.

public Expression

Returns:

The expression representing the entity type
getEntityType
()

Returns the Expression that represents the entity type that will be used to downcast the type of the elements in the collection.

public JPQLQueryBNF
public boolean

Returns:

true if the identifier AS was parsed; false otherwise
hasAs
()

Determines whether the identifier AS was parsed.

public boolean

Returns:

true if the collection-valued path expression was parsed; false if nothing was parsed
hasCollectionValuedPathExpression
()

Determines whether the collection-valued path expression of the query was parsed.

public boolean
hasEncapsulatedExpression()

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

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

Returns:

true if the entity type was parsed; false if nothing was parsed
hasEntityType
()

Determines whether the entity type was parsed.

public boolean

Returns:

true if there was a whitespace after AS; false otherwise
hasSpaceAfterAs
()

Determines whether a whitespace was parsed after AS.

public boolean

Returns:

true if a whitespace was parsed after the collection-valued path expression; false otherwise
hasSpaceAfterCollectionValuedPathExpression
()

Determines whether a whitespace was parsed after the collection-valued path expression.

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

asIdentifierback to summary
private String asIdentifier

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

collectionValuedPathExpressionback to summary
private AbstractExpression collectionValuedPathExpression

The Expression that represents the collection-valued path expression.

entityTypeback to summary
private AbstractExpression entityType

The entity type used to downcast the type of the elements in the collection.

hasSpaceAfterAsback to summary
private boolean hasSpaceAfterAs

Determines whether a whitespace was parsed after AS.

hasSpaceAfterCollectionValuedPathExpressionback to summary
private boolean hasSpaceAfterCollectionValuedPathExpression

Determines whether a whitespace was parsed after the collection-valued path expression.

parameterIndexback to summary
private int parameterIndex

Determines which child expression is been currently parsed.

Constructor Detail

TreatExpressionback to summary
public TreatExpression(AbstractExpression parent)

Creates a new TreatExpression.

Parameters
parent:AbstractExpression

The parent of this expression

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
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
findQueryBNFback to summary
public final 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
getActualAsIdentifierback to summary
public String getActualAsIdentifier()

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

Returns:String

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

getCollectionValuedPathExpressionback to summary
public Expression getCollectionValuedPathExpression()

Returns the Expression that represents the collection-valued path expression.

Returns:Expression

The expression that represents the collection-valued path expression

getEntityTypeback to summary
public Expression getEntityType()

Returns the Expression that represents the entity type that will be used to downcast the type of the elements in the collection.

Returns:Expression

The expression representing the entity type

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
hasAsback to summary
public boolean hasAs()

Determines whether the identifier AS was parsed.

Returns:boolean

true if the identifier AS was parsed; false otherwise

hasCollectionValuedPathExpressionback to summary
public boolean hasCollectionValuedPathExpression()

Determines whether the collection-valued path expression of the query was parsed.

Returns:boolean

true if the collection-valued path expression was parsed; false if nothing was parsed

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
hasEntityTypeback to summary
public boolean hasEntityType()

Determines whether the entity type was parsed.

Returns:boolean

true if the entity type was parsed; false if nothing was parsed

hasSpaceAfterAsback to summary
public boolean hasSpaceAfterAs()

Determines whether a whitespace was parsed after AS.

Returns:boolean

true if there was a whitespace after AS; false otherwise

hasSpaceAfterCollectionValuedPathExpressionback to summary
public boolean hasSpaceAfterCollectionValuedPathExpression()

Determines whether a whitespace was parsed after the collection-valued path expression.

Returns:boolean

true if a whitespace was parsed after the collection-valued path expression; false otherwise

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