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

public final Class InExpression

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

The state field path expression must have a string, numeric, or enum value. The literal and/or input parameter values must be like the same abstract schema type of the state field path expression in type.

The results of the subquery must be like the same abstract schema type of the state field path expression in type.

There must be at least one element in the comma separated list that defines the set of values for the IN expression. If the value of a state field path expression in an IN or NOT IN expression is NULL or unknown, the value of the expression is unknown.

JPA 1.0:

BNF: in_expression ::= state_field_path_expression [NOT] IN(in_item {, in_item}* | subquery)

JPA 2.0:
BNF: in_expression ::= {state_field_path_expression | type_discriminator} [NOT] IN { ( in_item {, in_item}* ) | (subquery) | collection_valued_input_parameter }

EclipseLink 2.1:

BNF: in_item ::= literal | single_valued_input_parameter | scalar_expression

EclipseLink 2.5:

BNF:
 in_expression ::= { in_expression_expression | nested_array_expression } [NOT] IN { ( in_item {, in_item}* ) | (subquery) | ( nested_array_item {, nested_array_item}+ ) | collection_valued_input_parameter }

in_expression_expression ::= { state_field_path_expression | type_discriminator |
                               single_valued_input_parameter | identification_variable |
                               scalar_expression }

nested_array_expression ::= ( in_expression_expression {, in_expression_expression}+ )

nested_array_item ::= ( in_item {, in_item}+ )
Example: SELECT c FROM Customer c WHERE c.home.city IN :city
Example: SELECT p FROM Project p WHERE TYPE(p) IN(LargeProject, SmallProject)
Author
Pascal Filion
Since
2.3
Version
2.5.1

Field Summary

Modifier and TypeField and Description
private AbstractExpression
expression

The expression before the 'IN' identifier used for identification.

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
hasSpaceAfterIn

Flag used to determine if a space was parsed after IN if the left parenthesis was not parsed.

private String
inIdentifier

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

private AbstractExpression
inItems

The expression within parenthesis, which can be one or many expressions.

private String
notIdentifier

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

private Boolean
singleInputParameter

Determines whether what was parsed after the IN identifier is a single input parameter.

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
InExpression(AbstractExpression
The parent of this expression
parent
,
AbstractExpression
The state field path expression that was parsed prior of parsing this expression
expression
)

Creates a new InExpression.

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 IN identifier that was actually parsed
getActualInIdentifier
()

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

public String

Returns:

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

Returns the actual NOT 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 state field path expression or the type discriminator
getExpression
()

Returns the Expression that represents the state field path expression or type discriminator.

public String
getExpressionExpressionQueryBNFId()

Returns the unique identifier of the query BNF that describes the expression being tested by the IN expression.

public String
getExpressionItemQueryBNFId()

Returns the unique identifier of the query BNF that describes the items being tested against.

public String

Returns:

Either IS IN or IN
getIdentifier
()

Returns the identifier for this expression.

public Expression

Returns:

The expression that was parsed representing the list of items
getInItems
()

Returns the Expression that represents the list if items.

public JPQLQueryBNF
public boolean

Returns:

true if the state field path expression or type discriminator was parsed; false if it was not parsed
hasExpression
()

Determines whether the state field path expression or type discriminator was parsed.

public boolean

Returns:

true if at least one item was parsed; false otherwise
hasInItems
()

Determines whether the list of items was parsed.

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

Returns:

true if the identifier NOT was parsed; false otherwise
hasNot
()

Determines whether the identifier NOT was parsed.

public 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 IN in the string version of the query; false otherwise
hasSpaceAfterIn
()

Determines whether there was a whitespace after the IN identifier if the left parenthesis was not 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.
public boolean

Returns:

true if what is following the IN identifier is a single input parameter (without the left or right parenthesis); false otherwise
isSingleInputParameter
()

Determines whether what was parsed after the IN identifier is a single input parameter:

BNF: in_expression ::= {state_field_path_expression | type_discriminator} [NOT] IN collection_valued_input_parameter
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

expressionback to summary
private AbstractExpression expression

The expression before the 'IN' identifier used for identification.

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.

hasSpaceAfterInback to summary
private boolean hasSpaceAfterIn

Flag used to determine if a space was parsed after IN if the left parenthesis was not parsed.

inIdentifierback to summary
private String inIdentifier

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

inItemsback to summary
private AbstractExpression inItems

The expression within parenthesis, which can be one or many expressions.

notIdentifierback to summary
private String notIdentifier

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

singleInputParameterback to summary
private Boolean singleInputParameter

Determines whether what was parsed after the IN identifier is a single input parameter.

Constructor Detail

InExpressionback to summary
public InExpression(AbstractExpression parent, AbstractExpression expression)

Creates a new InExpression.

Parameters
parent:AbstractExpression

The parent of this expression

expression:AbstractExpression

The state field path expression that was parsed prior of parsing 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
getActualInIdentifierback to summary
public String getActualInIdentifier()

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

Returns:String

The IN identifier that was actually parsed

getActualNotIdentifierback to summary
public String getActualNotIdentifier()

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

Returns:String

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

getExpressionback to summary
public Expression getExpression()

Returns the Expression that represents the state field path expression or type discriminator.

Returns:Expression

The expression that was parsed representing the state field path expression or the type discriminator

getExpressionExpressionQueryBNFIdback to summary
public String getExpressionExpressionQueryBNFId()

Returns the unique identifier of the query BNF that describes the expression being tested by the IN expression.

Returns:String

InExpressionExpressionBNF#ID

getExpressionItemQueryBNFIdback to summary
public String getExpressionItemQueryBNFId()

Returns the unique identifier of the query BNF that describes the items being tested against.

Returns:String

InExpressionItemBNF#ID

getIdentifierback to summary
public String getIdentifier()

Returns the identifier for this expression.

Returns:String

Either IS IN or IN

getInItemsback to summary
public Expression getInItems()

Returns the Expression that represents the list if items.

Returns:Expression

The expression that was parsed representing the list of items

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
hasExpressionback to summary
public boolean hasExpression()

Determines whether the state field path expression or type discriminator was parsed.

Returns:boolean

true if the state field path expression or type discriminator was parsed; false if it was not parsed

hasInItemsback to summary
public boolean hasInItems()

Determines whether the list of items was parsed.

Returns:boolean

true if at least one item was parsed; false otherwise

hasLeftParenthesisback to summary
public 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

hasNotback to summary
public boolean hasNot()

Determines whether the identifier NOT was parsed.

Returns:boolean

true if the identifier NOT was parsed; false otherwise

hasRightParenthesisback to summary
public 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

hasSpaceAfterInback to summary
public boolean hasSpaceAfterIn()

Determines whether there was a whitespace after the IN identifier if the left parenthesis was not parsed.

Returns:boolean

true if a whitespace was parsed after IN in the string version of the query; false otherwise

Since
2.4
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
isSingleInputParameterback to summary
public boolean isSingleInputParameter()

Determines whether what was parsed after the IN identifier is a single input parameter:

BNF: in_expression ::= {state_field_path_expression | type_discriminator} [NOT] IN collection_valued_input_parameter
Returns:boolean

true if what is following the IN identifier is a single input parameter (without the left or right parenthesis); false otherwise

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