Top Description Fields Constructors Methods
org.eclipse.persistence.jpa.jpql.tools.model.query

public Class ComparisonExpressionStateObject

extends CompoundExpressionStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls
Imports
org.eclipse.persistence.jpa.jpql.Assert, org.eclipse.persistence.jpa.jpql.parser.ComparisonExpression, .ComparisonExpressionBNF

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}
Author
Pascal Filion
Since
2.4
Version
2.4
See Also
ComparisonExpression

Field Summary

Modifier and TypeField and Description
private String
identifier

The comparison identifier, which is either <, <=, =, >=, <>.

public static final String
IDENTIFIER_PROPERTY

Notifies the identifier property has changed.

Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject:
LEFT_STATE_OBJECT_PROPERTYRIGHT_STATE_OBJECT_PROPERTY

Constructor Summary

AccessConstructor and Description
public
ComparisonExpressionStateObject(StateObject
The parent of this state object, which cannot be null
parent
,
StateObject
The StateObject representing the left expression
leftStateObject
,
String
The comparison identifier, either <, <=, =, >=, <>
identifier
,
StateObject
The StateObject representing the right expression
rightStateObject
)

Creates a new ComparisonExpressionStateObject.

public
ComparisonExpressionStateObject(StateObject
The parent of this state object, which cannot be null
parent
,
String
The comparison identifier, either <, <=, =, >=, <>
identifier
)

Creates a new ComparisonExpressionStateObject.

public
ComparisonExpressionStateObject(StateObject
The parent of this state object, which cannot be null
parent
,
String
The string representation of the left expression to parse and to convert into a StateObject
leftJpqlFragment
,
String
The comparison identifier, either <, <=, =, >=, <>
identifier
,
String
The string representation of the right expression to parse and to convert into a StateObject
rightJpqlFragment
)

Creates a new ComparisonExpressionStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
public ComparisonExpression
getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

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

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.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 String
getRightQueryBNFId()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.getRightQueryBNFId.

Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the right side of the expression.
public boolean
isEquivalent(StateObject
The StateObject to compare its content to this one
stateObject
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.
public void
setExpression(ComparisonExpression
The parsed object representing a comparison expression
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.

public void
setIdentifier(String
The new comparison identifier, either <, <=, =, >=, <>
identifier
)

Sets the comparison identifier to one of the following: <, <=, =, >=, <>.

protected void
Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject:
addChildrengetLeftgetRighthasLefthasRightparseLeftparseRightsetLeftsetRighttoTextInternal

Field Detail

identifierback to summary
private String identifier

The comparison identifier, which is either <, <=, =, >=, <>.

IDENTIFIER_PROPERTYback to summary
public static final String IDENTIFIER_PROPERTY

Notifies the identifier property has changed.

Constructor Detail

ComparisonExpressionStateObjectback to summary
public ComparisonExpressionStateObject(StateObject parent, StateObject leftStateObject, String identifier, StateObject rightStateObject)

Creates a new ComparisonExpressionStateObject.

Parameters
parent:StateObject

The parent of this state object, which cannot be null

leftStateObject:StateObject

The StateObject representing the left expression

identifier:String

The comparison identifier, either <, <=, =, >=, <>

rightStateObject:StateObject

The StateObject representing the right expression

Exceptions
NullPointerException:
The given parent cannot be null
ComparisonExpressionStateObjectback to summary
public ComparisonExpressionStateObject(StateObject parent, String identifier)

Creates a new ComparisonExpressionStateObject.

Parameters
parent:StateObject

The parent of this state object, which cannot be null

identifier:String

The comparison identifier, either <, <=, =, >=, <>

Exceptions
NullPointerException:
The given parent cannot be null
ComparisonExpressionStateObjectback to summary
public ComparisonExpressionStateObject(StateObject parent, String leftJpqlFragment, String identifier, String rightJpqlFragment)

Creates a new ComparisonExpressionStateObject.

Parameters
parent:StateObject

The parent of this state object, which cannot be null

leftJpqlFragment:String

The string representation of the left expression to parse and to convert into a StateObject

identifier:String

The comparison identifier, either <, <=, =, >=, <>

rightJpqlFragment:String

The string representation of the right expression to parse and to convert into a StateObject

Exceptions
NullPointerException:
The given parent cannot be null

Method Detail

acceptback to summary
public void accept(StateObjectVisitor visitor)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.accept.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.accept.

Visits this StateObject by the given visitor.

Parameters
visitor:StateObjectVisitor

The visitor to visit this object

Annotations
@Override
getExpressionback to summary
public ComparisonExpression getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.getExpression.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.getExpression.

Returns the actual parsed object if this StateObject representation of the JPQL query was created by parsing an existing JPQL query.

Returns:ComparisonExpression

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)

Annotations
@Override
getIdentifierback to summary
public String getIdentifier()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.getIdentifier.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.getIdentifier.

Returns the identifier joining the two StateObjects.

Returns:String

The JPQL identifier join two expressions

Annotations
@Override
getLeftQueryBNFIdback to summary
protected String getLeftQueryBNFId()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.getLeftQueryBNFId.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.getLeftQueryBNFId.

Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the left side of the expression.

Returns:String

The query BNF ID for the left side of the expression

Annotations
@Override
getRightQueryBNFIdback to summary
protected String getRightQueryBNFId()

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.getRightQueryBNFId.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.getRightQueryBNFId.

Returns the unique identifier of the BNF that will be used to parse a JPQL fragment as the right side of the expression.

Returns:String

The query BNF ID for the right side of the expression

Annotations
@Override
isEquivalentback to summary
public boolean isEquivalent(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject.isEquivalent.

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject.isEquivalent.

Determines whether the given StateObject is equivalent to this one, i.e. the information of both StateObject is the same.

Parameters
stateObject:StateObject

The StateObject to compare its content to this one

Returns:boolean

true if both object are equivalent; false otherwise

Annotations
@Override
setExpressionback to summary
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:ComparisonExpression

The parsed object representing a comparison expression

setIdentifierback to summary
public void setIdentifier(String identifier)

Sets the comparison identifier to one of the following: <, <=, =, >=, <>.

Parameters
identifier:String

The new comparison identifier, either <, <=, =, >=, <>

validateIdentifierback to summary
protected void validateIdentifier(String identifier)