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

public final Class CaseExpression

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

BNF: general_case_expression ::= CASE when_clause {when_clause}* ELSE scalar_expression END
or
BNF: simple_case_expression ::= CASE case_operand simple_when_clause {simple_when_clause}* ELSE scalar_expression END
Author
Pascal Filion
Since
2.3
Version
2.5

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static enum

Field Summary

Modifier and TypeField and Description
private String
caseIdentifier

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

private AbstractExpression
caseOperand

The Expression representing the case operand.

private AbstractExpression
elseExpression

The Expression representing the ELSE expression.

private String
elseIdentifier

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

private String
endIdentifier

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

private boolean
hasSpaceAfterCase

Determines whether a whitespace was parsed after CASE.

private boolean
hasSpaceAfterCaseOperand

Determines whether a whitespace was parsed after the case operand.

private boolean
hasSpaceAfterElse

Determines whether a whitespace was parsed after ELSE.

private boolean
hasSpaceAfterElseExpression

Determines whether a whitespace was parsed after the BETWEEN expression.

private boolean
hasSpaceAfterWhenClauses

Determines whether a whitespace was parsed after WHEN clause.

private CaseExpression.ParsingType
parsingType

Used to determine how to check if the parsing is complete.

private AbstractExpression
whenClauses

The Expression representing the WHEN clauses.

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
CaseExpression(AbstractExpression
The parent of this expression
parent
)

Creates a new CaseExpression.

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
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 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 CASE identifier that was actually parsed
getActualCaseIdentifier
()

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

public String

Returns:

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

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

public String

Returns:

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

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

public Expression

Returns:

The expression that was parsed representing the CASE operand
getCaseOperand
()

Returns the Expression that represents the CASE operand.

public AbstractExpression

Returns:

The expression that was parsed representing the ELSE operand
getElseExpression
()

Returns the Expression that represents the ELSE operand.

public JPQLQueryBNF
public AbstractExpression

Returns:

The expression that was parsed representing the WHEN clauses
getWhenClauses
()

Returns the Expression that represents the WHEN clauses.

public boolean

Returns:

true if the CASE operand was parsed; false otherwise
hasCaseOperand
()

Determines whether the CASE operand was parsed.

public boolean

Returns:

true if the identifier ELSE was parsed; false otherwise
hasElse
()

Determines whether the identifier ELSE was parsed.

public boolean

Returns:

true if the ELSE expression was parsed; false otherwise
hasElseExpression
()

Determines whether the ELSE expression was parsed.

public boolean

Returns:

true if the identifier END was parsed; false otherwise
hasEnd
()

Determines whether the identifier END was parsed.

public boolean

Returns:

true if there was a whitespace after CASE; false otherwise
hasSpaceAfterCase
()

Determines whether a whitespace was parsed after CASE.

public boolean

Returns:

true if there was a whitespace after the case operand; false otherwise
hasSpaceAfterCaseOperand
()

Determines whether a whitespace was parsed after the case operand.

public boolean

Returns:

true if there was a whitespace after ELSE; false otherwise
hasSpaceAfterElse
()

Determines whether a whitespace was parsed after ELSE.

public boolean

Returns:

true if there was a whitespace after the else expression; false otherwise
hasSpaceAfterElseExpression
()

Determines whether a whitespace was parsed after the else expression.

public boolean

Returns:

true if there was a whitespace after the WHEN clause; false otherwise
hasSpaceAfterWhenClauses
()

Determines whether a whitespace was parsed after the WHEN clause.

public boolean

Returns:

true if the WHEN clauses were parsed; false otherwise
hasWhenClauses
()

Determines whether the WHEN clauses were 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.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 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:
acceptUnknownVisitoracceptUnknownVisitorbuildExpressionFromFallingBackbuildNullExpressionbuildStringExpressionbuildStringExpressionbuildUnknownExpressioncalculatePositionchildrenfindFallBackExpressionFactorygetExpressionFactorygetExpressionRegistrygetGrammargetIdentifierVersiongetJPAVersiongetLengthgetOffsetgetParentgetQueryBNFgetRootgetTexthandleAggregatehandleCollectionisAncestorisIdentifierisNullisTolerantisUnknownisVirtualorderedChildrenparseparseUsingExpressionFactorypopulatePositionrebuildActualTextrebuildParsedTextsetParentsetTextshouldParseWithFactoryFirstshouldSkipLiteraltoActualTexttoParsedTexttoString

Field Detail

caseIdentifierback to summary
private String caseIdentifier

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

caseOperandback to summary
private AbstractExpression caseOperand

The Expression representing the case operand.

elseExpressionback to summary
private AbstractExpression elseExpression

The Expression representing the ELSE expression.

elseIdentifierback to summary
private String elseIdentifier

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

endIdentifierback to summary
private String endIdentifier

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

hasSpaceAfterCaseback to summary
private boolean hasSpaceAfterCase

Determines whether a whitespace was parsed after CASE.

hasSpaceAfterCaseOperandback to summary
private boolean hasSpaceAfterCaseOperand

Determines whether a whitespace was parsed after the case operand.

hasSpaceAfterElseback to summary
private boolean hasSpaceAfterElse

Determines whether a whitespace was parsed after ELSE.

hasSpaceAfterElseExpressionback to summary
private boolean hasSpaceAfterElseExpression

Determines whether a whitespace was parsed after the BETWEEN expression.

hasSpaceAfterWhenClausesback to summary
private boolean hasSpaceAfterWhenClauses

Determines whether a whitespace was parsed after WHEN clause.

parsingTypeback to summary
private CaseExpression.ParsingType parsingType

Used to determine how to check if the parsing is complete.

whenClausesback to summary
private AbstractExpression whenClauses

The Expression representing the WHEN clauses.

Constructor Detail

CaseExpressionback to summary
public CaseExpression(AbstractExpression parent)

Creates a new CaseExpression.

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
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
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
getActualCaseIdentifierback to summary
public String getActualCaseIdentifier()

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

Returns:String

The CASE identifier that was actually parsed

getActualElseIdentifierback to summary
public String getActualElseIdentifier()

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

Returns:String

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

getActualEndIdentifierback to summary
public String getActualEndIdentifier()

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

Returns:String

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

getCaseOperandback to summary
public Expression getCaseOperand()

Returns the Expression that represents the CASE operand.

Returns:Expression

The expression that was parsed representing the CASE operand

getElseExpressionback to summary
public AbstractExpression getElseExpression()

Returns the Expression that represents the ELSE operand.

Returns:AbstractExpression

The expression that was parsed representing the ELSE operand

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
getWhenClausesback to summary
public AbstractExpression getWhenClauses()

Returns the Expression that represents the WHEN clauses.

Returns:AbstractExpression

The expression that was parsed representing the WHEN clauses

hasCaseOperandback to summary
public boolean hasCaseOperand()

Determines whether the CASE operand was parsed.

Returns:boolean

true if the CASE operand was parsed; false otherwise

hasElseback to summary
public boolean hasElse()

Determines whether the identifier ELSE was parsed.

Returns:boolean

true if the identifier ELSE was parsed; false otherwise

hasElseExpressionback to summary
public boolean hasElseExpression()

Determines whether the ELSE expression was parsed.

Returns:boolean

true if the ELSE expression was parsed; false otherwise

hasEndback to summary
public boolean hasEnd()

Determines whether the identifier END was parsed.

Returns:boolean

true if the identifier END was parsed; false otherwise

hasSpaceAfterCaseback to summary
public boolean hasSpaceAfterCase()

Determines whether a whitespace was parsed after CASE.

Returns:boolean

true if there was a whitespace after CASE; false otherwise

hasSpaceAfterCaseOperandback to summary
public boolean hasSpaceAfterCaseOperand()

Determines whether a whitespace was parsed after the case operand.

Returns:boolean

true if there was a whitespace after the case operand; false otherwise

hasSpaceAfterElseback to summary
public boolean hasSpaceAfterElse()

Determines whether a whitespace was parsed after ELSE.

Returns:boolean

true if there was a whitespace after ELSE; false otherwise

hasSpaceAfterElseExpressionback to summary
public boolean hasSpaceAfterElseExpression()

Determines whether a whitespace was parsed after the else expression.

Returns:boolean

true if there was a whitespace after the else expression; false otherwise

hasSpaceAfterWhenClausesback to summary
public boolean hasSpaceAfterWhenClauses()

Determines whether a whitespace was parsed after the WHEN clause.

Returns:boolean

true if there was a whitespace after the WHEN clause; false otherwise

hasWhenClausesback to summary
public boolean hasWhenClauses()

Determines whether the WHEN clauses were parsed.

Returns:boolean

true if the WHEN clauses were parsed; 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
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
org.eclipse.persistence.jpa.jpql.parser back to summary

private final Enum CaseExpression.ParsingType

extends Enum<CaseExpression.ParsingType>
Class Inheritance

A enumeration used to determine how CaseExpression#isParsingComplete(WordParser, String, Expression) should behaves.

Field Summary

Modifier and TypeField and Description
public static final CaseExpression.ParsingType
public static final CaseExpression.ParsingType
public static final CaseExpression.ParsingType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static CaseExpression.ParsingType
public static CaseExpression.ParsingType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CASEback to summary
public static final CaseExpression.ParsingType CASE
ELSEback to summary
public static final CaseExpression.ParsingType ELSE
WHENback to summary
public static final CaseExpression.ParsingType WHEN

Constructor Detail

ParsingTypeback to summary
private ParsingType()

Method Detail

valueOfback to summary
public static CaseExpression.ParsingType valueOf(String name)
valuesback to summary
public static CaseExpression.ParsingType[] values()