org.eclipse.persistence.jpa.jpql.tools.model.query.AndExpressionStateObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of eclipselink Show documentation
Show all versions of eclipselink Show documentation
EclipseLink build based upon Git transaction 180e602
/*******************************************************************************
* Copyright (c) 2011, 2014 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.tools.model.query;
import org.eclipse.persistence.jpa.jpql.parser.AndExpression;
import org.eclipse.persistence.jpa.jpql.parser.ConditionalFactorBNF;
import org.eclipse.persistence.jpa.jpql.parser.ConditionalTermBNF;
import static org.eclipse.persistence.jpa.jpql.parser.Expression.*;
/**
* The AND
logical operator chains multiple criteria together. A valid operand
* of an AND
operator must be one of: TRUE
,
* FALSE
, and NULL
. The AND
operator has
* a higher precedence than the OR
operator.
*
* NULL
represents unknown. Therefore, if one operand is NULL
* and the other operand is FALSE
the result is FALSE
,
* because one FALSE
operand is sufficient for a FALSE
* result. If one operand is NULL
and the other operand is either
* TRUE
or NULL
, the result is NULL
* (unknown).
*
* The following table shows how the AND
operator is evaluated based on its two
* operands:
*
*
* TRUE FALSE NULL
* TRUE TRUE FALSE NULL
* FALSE FALSE FALSE FALSE
* NULL NULL FALSE NULL
*
*
* BNF: conditional_term ::= conditional_term AND conditional_factor
*
* @see AndExpression
*
* @version 2.4
* @since 2.4
* @author Pascal Filion
*/
public class AndExpressionStateObject extends LogicalExpressionStateObject {
/**
* Creates a new AndExpressionStateObject
.
*
* @param parent The parent of this state object, which cannot be null
* @exception NullPointerException The given parent cannot be null
*/
public AndExpressionStateObject(StateObject parent) {
super(parent);
}
/**
* Creates a new AndExpressionStateObject
.
*
* @param parent The parent of this state object, which cannot be null
* @param leftStateObject The {@link StateObject} representing the left expression
* @param rightStateObject The {@link StateObject} representing the right expression
* @exception NullPointerException The given parent cannot be null
*/
public AndExpressionStateObject(StateObject parent,
StateObject leftStateObject,
StateObject rightStateObject) {
super(parent, leftStateObject, rightStateObject);
}
/**
* Creates a new AndExpressionStateObject
.
*
* @param parent The parent of this state object, which cannot be null
* @param leftJpqlFragment The string representation of the left expression to parse and to
* convert into a {@link StateObject}
* @param rightJpqlFragment The string representation of the right expression to parse and to
* convert into a {@link StateObject}
* @exception NullPointerException The given parent cannot be null
*/
public AndExpressionStateObject(StateObject parent,
String leftJpqlFragment,
String rightJpqlFragment) {
super(parent, leftJpqlFragment, rightJpqlFragment);
}
/**
* {@inheritDoc}
*/
public void accept(StateObjectVisitor visitor) {
visitor.visit(this);
}
/**
* {@inheritDoc}
*/
@Override
public AndExpression getExpression() {
return (AndExpression) super.getExpression();
}
/**
* {@inheritDoc}
*/
@Override
public String getIdentifier() {
return AND;
}
/**
* {@inheritDoc}
*/
@Override
protected String getLeftQueryBNFId() {
return ConditionalTermBNF.ID;
}
/**
* {@inheritDoc}
*/
@Override
protected String getRightQueryBNFId() {
return ConditionalFactorBNF.ID;
}
/**
* Keeps a reference of the {@link AndExpression parsed object} object, which should only be
* done when this object is instantiated during the conversion of a parsed JPQL query into
* {@link StateObject StateObjects}.
*
* @param expression The {@link AndExpression parsed object} representing a logical
* AND
expression
*/
public void setExpression(AndExpression expression) {
super.setExpression(expression);
}
}