
org.eclipse.persistence.jpa.jpql.parser.AllOrAnyExpression Maven / Gradle / Ivy
Show all versions of eclipselink Show documentation
/*******************************************************************************
* Copyright (c) 2006, 2013 Oracle and/or its affiliates. All rights reserved.
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v1.0 and Eclipse Distribution License v. 1.0
* which accompanies this distribution.
* The Eclipse Public License is available at http://www.eclipse.org/legal/epl-v10.html
* and the Eclipse Distribution License is available at
* http://www.eclipse.org/org/documents/edl-v10.php.
*
* Contributors:
* Oracle - initial API and implementation
*
******************************************************************************/
package org.eclipse.persistence.jpa.jpql.parser;
import org.eclipse.persistence.jpa.jpql.WordParser;
/**
* An ALL conditional expression is a predicate that is true
if the comparison
* operation is true
for all values in the result of the subquery or the result of the
* subquery is empty. An ALL conditional expression is false
if the result of
* the comparison is false
for at least one row, and is unknown if neither
* true
nor false
.
*
* An ANY conditional expression is a predicate that is true
if the comparison
* operation is true
for some value in the result of the subquery. An ANY
* conditional expression is false
if the result of the subquery is empty or if the
* comparison operation is false
for every value in the result of the subquery, and is
* unknown if neither true
nor false
. The keyword SOME is
* synonymous with ANY. The comparison operators used with ALL or ANY
* conditional expressions are =, <, <=, >, >=, <>. The result of the subquery must be like that of
* the other argument to the comparison operator in type.
*
*
BNF: all_or_any_expression ::= {ALL|ANY|SOME}(subquery)
*
* @version 2.4
* @since 2.3
* @author Pascal Filion
*/
public final class AllOrAnyExpression extends AbstractSingleEncapsulatedExpression {
/**
* Creates a new AllOrAnyExpression
.
*
* @param parent The parent of this expression
*/
public AllOrAnyExpression(AbstractExpression parent) {
super(parent);
}
/**
* {@inheritDoc}
*/
public void accept(ExpressionVisitor visitor) {
visitor.visit(this);
}
/**
* {@inheritDoc}
*/
@Override
public String encapsulatedExpressionBNF() {
return SubqueryBNF.ID;
}
/**
* {@inheritDoc}
*/
public JPQLQueryBNF getQueryBNF() {
return getQueryBNF(AllOrAnyExpressionBNF.ID);
}
/**
* {@inheritDoc}
*/
@Override
protected AbstractExpression parse(WordParser wordParser, String queryBNFId, boolean tolerant) {
if (tolerant) {
return super.parse(wordParser, queryBNFId, tolerant);
}
SimpleSelectStatement expression = new SimpleSelectStatement(this);
expression.parse(wordParser, tolerant);
return expression;
}
/**
* {@inheritDoc}
*/
@Override
protected String parseIdentifier(WordParser wordParser) {
switch (wordParser.character()) {
case 's': case 'S': {
return SOME;
}
default: {
switch (wordParser.character(wordParser.position() + 1)) {
case 'l': case 'L': {
return ALL;
}
default: {
return ANY;
}
}
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy