EclipseLink 2.4.2, build 'v20130514-5956486' API Reference

org.eclipse.persistence.jpa.jpql.model.query
Class ComparisonExpressionStateObject

java.lang.Object
  extended by org.eclipse.persistence.jpa.jpql.model.query.AbstractStateObject
      extended by org.eclipse.persistence.jpa.jpql.model.query.CompoundExpressionStateObject
          extended by org.eclipse.persistence.jpa.jpql.model.query.ComparisonExpressionStateObject
All Implemented Interfaces:
StateObject

public class ComparisonExpressionStateObject
extends CompoundExpressionStateObject

Only the values of like types are permitted to be compared. A type is like another type if they correspond to the same Java language type, or if one is a primitive Java language type and the other is the wrapped Java class type equivalent (e.g., int and Integer are like types in this sense).

There is one exception to this rule: it is valid to compare numeric values for which the rules of numeric promotion apply. Conditional expressions attempting to compare non-like type values are disallowed except for this numeric case.

Note that the arithmetic operators and comparison operators are permitted to be applied to state-fields and input parameters of the wrapped Java class equivalents to the primitive numeric Java types. Two entities of the same abstract schema type are equal if and only if they have the same primary key value. Only equality/inequality comparisons over enumeration constants are required to be supported.

JPA 1.0 - BNF:

comparison_expression ::= string_expression comparison_operator {string_expression | all_or_any_expression} |
                          boolean_expression {=|<>} {boolean_expression | all_or_any_expression} |
                          enum_expression {=|<>} {enum_expression | all_or_any_expression} |
                          datetime_expression comparison_operator {datetime_expression | all_or_any_expression} |
                          entity_expression {=|<>} {entity_expression | all_or_any_expression} |
                          arithmetic_expression comparison_operator {arithmetic_expression | all_or_any_expression}
JPA 2.0 - BNF:
comparison_expression ::= string_expression comparison_operator {string_expression | all_or_any_expression} |
                          boolean_expression {=|<>} {boolean_expression | all_or_any_expression} |
                          enum_expression {=|<>} {enum_expression | all_or_any_expression} |
                          datetime_expression comparison_operator {datetime_expression | all_or_any_expression} |
                          entity_expression {=|<>} {entity_expression | all_or_any_expression} |
                          arithmetic_expression comparison_operator {arithmetic_expression | all_or_any_expression} |
                          entity_type_expression {=|<>} entity_type_expression}

Version:
2.4
See Also:
ComparisonExpression
Author:
Pascal Filion
Since:
2.4

Field Summary
static java.lang.String IDENTIFIER_PROPERTY
          Notifies the identifier property has changed.
 
Fields inherited from class org.eclipse.persistence.jpa.jpql.model.query.CompoundExpressionStateObject
LEFT_STATE_OBJECT_PROPERTY, RIGHT_STATE_OBJECT_PROPERTY
 
Constructor Summary
ComparisonExpressionStateObject(StateObject parent, StateObject leftStateObject, java.lang.String identifier, StateObject rightStateObject)
          Creates a new ComparisonExpressionStateObject.
ComparisonExpressionStateObject(StateObject parent, java.lang.String identifier)
          Creates a new ComparisonExpressionStateObject.
ComparisonExpressionStateObject(StateObject parent, java.lang.String leftJpqlFragment, java.lang.String identifier, java.lang.String rightJpqlFragment)
          Creates a new ComparisonExpressionStateObject.
 
Method Summary
 void accept(StateObjectVisitor visitor)
          Visits this StateObject by the given visitor.
 ComparisonExpression getExpression()
          Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.
 java.lang.String getIdentifier()
          Returns the identifier joining the two StateObjects.
protected  java.lang.String getLeftQueryBNFId()
          Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the left side of the expression.
protected  java.lang.String getRightQueryBNFId()
          Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the right side of the expression.
 boolean isEquivalent(StateObject stateObject)
          Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
 void setExpression(ComparisonExpression expression)
          Keeps a reference of the parsed object object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query into StateObjects.
 void setIdentifier(java.lang.String identifier)
          Sets the comparison identifier to one of the following: <, <=, =, >=, <>.
protected  void validateIdentifier(java.lang.String identifier)
           
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.model.query.CompoundExpressionStateObject
addChildren, getLeft, getRight, hasLeft, hasRight, parseLeft, parseRight, setLeft, setRight, toTextInternal
 
Methods inherited from class org.eclipse.persistence.jpa.jpql.model.query.AbstractStateObject
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getParent, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, initialize, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toText
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

IDENTIFIER_PROPERTY

public static final java.lang.String IDENTIFIER_PROPERTY
Notifies the identifier property has changed.

See Also:
Constant Field Values
Constructor Detail

ComparisonExpressionStateObject

public ComparisonExpressionStateObject(StateObject parent,
                                       StateObject leftStateObject,
                                       java.lang.String identifier,
                                       StateObject rightStateObject)
Creates a new ComparisonExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
leftStateObject - The StateObject representing the left expression
identifier - The comparison identifier, either <, <=, =, >=, <>
rightStateObject - The StateObject representing the right expression
Throws:
java.lang.NullPointerException - The given parent cannot be null

ComparisonExpressionStateObject

public ComparisonExpressionStateObject(StateObject parent,
                                       java.lang.String identifier)
Creates a new ComparisonExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
identifier - The comparison identifier, either <, <=, =, >=, <>
Throws:
java.lang.NullPointerException - The given parent cannot be null

ComparisonExpressionStateObject

public ComparisonExpressionStateObject(StateObject parent,
                                       java.lang.String leftJpqlFragment,
                                       java.lang.String identifier,
                                       java.lang.String rightJpqlFragment)
Creates a new ComparisonExpressionStateObject.

Parameters:
parent - The parent of this state object, which cannot be null
leftJpqlFragment - The string representation of the left expression to parse and to convert into a StateObject
identifier - The comparison identifier, either <, <=, =, >=, <>
rightJpqlFragment - The string representation of the right expression to parse and to convert into a StateObject
Throws:
java.lang.NullPointerException - The given parent cannot be null
Method Detail

accept

public void accept(StateObjectVisitor visitor)
Visits this StateObject by the given visitor.

Parameters:
visitor - The visitor to visit this object

getExpression

public ComparisonExpression getExpression()
Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Specified by:
getExpression in interface StateObject
Overrides:
getExpression in class CompoundExpressionStateObject
Returns:
The parsed object when a JPQL query is parsed and converted into a StateObject or null when the JPQL query is manually created (i.e. not from a string)

getIdentifier

public java.lang.String getIdentifier()
Returns the identifier joining the two StateObjects.

Specified by:
getIdentifier in class CompoundExpressionStateObject
Returns:
The JPQL identifier join two expressions

getLeftQueryBNFId

protected java.lang.String getLeftQueryBNFId()
Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the left side of the expression.

Specified by:
getLeftQueryBNFId in class CompoundExpressionStateObject
Returns:
The query BNF ID for the left side of the expression

getRightQueryBNFId

protected java.lang.String getRightQueryBNFId()
Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the right side of the expression.

Specified by:
getRightQueryBNFId in class CompoundExpressionStateObject
Returns:
The query BNF ID for the right side of the expression

isEquivalent

public boolean isEquivalent(StateObject stateObject)
Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Specified by:
isEquivalent in interface StateObject
Overrides:
isEquivalent in class CompoundExpressionStateObject
Parameters:
stateObject - The StateObject to compare its content to this one
Returns:
true if both object are equivalent; false otherwise

setExpression

public void setExpression(ComparisonExpression expression)
Keeps a reference of the parsed object object, which should only be done when this object is instantiated during the conversion of a parsed JPQL query into StateObjects.

Parameters:
expression - The parsed object representing a comparison expression

setIdentifier

public void setIdentifier(java.lang.String identifier)
Sets the comparison identifier to one of the following: <, <=, =, >=, <>.

Parameters:
identifier - The new comparison identifier, either <, <=, =, >=, <>

validateIdentifier

protected void validateIdentifier(java.lang.String identifier)

EclipseLink 2.4.2, build 'v20130514-5956486' API Reference