Class CompoundExpressionStateObject
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.CompoundExpressionStateObject
-
- All Implemented Interfaces:
StateObject
- Direct Known Subclasses:
ArithmeticExpressionStateObject
,ComparisonExpressionStateObject
,LogicalExpressionStateObject
public abstract class CompoundExpressionStateObject extends AbstractStateObject
A compoundStateObject
has a left and right expressions combined by an identifier.BNF:expression ::= left_expression <identifier> right_expression
- Version:
- 2.4
- See Also:
CompoundExpression
- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
LEFT_STATE_OBJECT_PROPERTY
Notifies the left state object property has changed.static java.lang.String
RIGHT_STATE_OBJECT_PROPERTY
Notifies the right state object property has changed.
-
Constructor Summary
Constructors Modifier Constructor Description protected
CompoundExpressionStateObject(StateObject parent)
Creates a newCompoundExpressionStateObject
.protected
CompoundExpressionStateObject(StateObject parent, java.lang.String leftJpqlFragment, java.lang.String rightJpqlFragment)
Creates a newArithmeticExpressionStateObject
.protected
CompoundExpressionStateObject(StateObject parent, StateObject leftStateObject, StateObject rightStateObject)
Creates a newArithmeticExpressionStateObject
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addChildren(java.util.List<StateObject> children)
Adds the children of thisStateObject
to the given list.CompoundExpression
getExpression()
Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.abstract java.lang.String
getIdentifier()
Returns the identifier joining the twoStateObjects
.StateObject
getLeft()
Returns theStateObject
that represents the left expression.protected abstract 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.StateObject
getRight()
Returns theStateObject
that represents the right expression.protected abstract 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
hasLeft()
Determines whether there is aStateObject
that represents the left expression.boolean
hasRight()
Determines whether there is aStateObject
that represents the right expression.boolean
isEquivalent(StateObject stateObject)
Determines whether the givenStateObject
is equivalent to this one, i.e. the information of bothStateObject
is the same.void
parseLeft(java.lang.String jpqlFragment)
Parses the given JPQL fragment and update the left side of the compound expression.void
parseRight(java.lang.String jpqlFragment)
Parses the given JPQL fragment and update the right side of the compound expression.void
setLeft(StateObject leftStateObject)
Sets the leftStateObject
to become the given object.void
setRight(StateObject rightStateObject)
Sets the rightStateObject
to become the given object.protected void
toTextInternal(java.lang.Appendable writer)
Prints out a string representation of thisStateObject
, which should not be used to define atrue
string representation of a JPQL query but should be used for debugging purposes.-
Methods inherited from class org.eclipse.persistence.jpa.jpql.tools.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
-
Methods inherited from interface org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
accept
-
-
-
-
Field Detail
-
LEFT_STATE_OBJECT_PROPERTY
public static final java.lang.String LEFT_STATE_OBJECT_PROPERTY
Notifies the left state object property has changed.- See Also:
- Constant Field Values
-
RIGHT_STATE_OBJECT_PROPERTY
public static final java.lang.String RIGHT_STATE_OBJECT_PROPERTY
Notifies the right state object property has changed.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
CompoundExpressionStateObject
protected CompoundExpressionStateObject(StateObject parent)
Creates a newCompoundExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
- Throws:
java.lang.NullPointerException
- The given parent cannot benull
-
CompoundExpressionStateObject
protected CompoundExpressionStateObject(StateObject parent, StateObject leftStateObject, StateObject rightStateObject)
Creates a newArithmeticExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
leftStateObject
- TheStateObject
representing the left expressionrightStateObject
- TheStateObject
representing the right expression- Throws:
java.lang.NullPointerException
- The given parent cannot benull
-
CompoundExpressionStateObject
protected CompoundExpressionStateObject(StateObject parent, java.lang.String leftJpqlFragment, java.lang.String rightJpqlFragment)
Creates a newArithmeticExpressionStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
leftJpqlFragment
- The string representation of the left expression to parse and to convert into aStateObject
rightJpqlFragment
- The string representation of the right expression to parse and to convert into aStateObject
- Throws:
java.lang.NullPointerException
- The given parent cannot benull
-
-
Method Detail
-
addChildren
protected void addChildren(java.util.List<StateObject> children)
Adds the children of thisStateObject
to the given list.- Overrides:
addChildren
in classAbstractStateObject
- Parameters:
children
- The list used to store the children
-
getExpression
public CompoundExpression getExpression()
Returns the actual parsed object if thisStateObject
representation of the JPQL query was created by parsing an existing JPQL query.- Specified by:
getExpression
in interfaceStateObject
- Overrides:
getExpression
in classAbstractStateObject
- Returns:
- The parsed object when a JPQL query is parsed and converted into a
StateObject
ornull
when the JPQL query is manually created (i.e. not from a string)
-
getIdentifier
public abstract java.lang.String getIdentifier()
Returns the identifier joining the twoStateObjects
.- Returns:
- The JPQL identifier join two expressions
-
getLeft
public StateObject getLeft()
Returns theStateObject
that represents the left expression.- Returns:
- The
StateObject
representing the left expression
-
getLeftQueryBNFId
protected abstract 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.- Returns:
- The query BNF ID for the left side of the expression
-
getRight
public StateObject getRight()
Returns theStateObject
that represents the right expression.- Returns:
- The
StateObject
representing the right expression
-
getRightQueryBNFId
protected abstract 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.- Returns:
- The query BNF ID for the right side of the expression
-
hasLeft
public boolean hasLeft()
Determines whether there is aStateObject
that represents the left expression.- Returns:
true
if there is a leftStateObject
;false
if it isnull
-
hasRight
public boolean hasRight()
Determines whether there is aStateObject
that represents the right expression.- Returns:
true
if there is a rightStateObject
;false
if it isnull
-
isEquivalent
public boolean isEquivalent(StateObject stateObject)
Determines whether the givenStateObject
is equivalent to this one, i.e. the information of bothStateObject
is the same.- Specified by:
isEquivalent
in interfaceStateObject
- Overrides:
isEquivalent
in classAbstractStateObject
- Parameters:
stateObject
- TheStateObject
to compare its content to this one- Returns:
true
if both object are equivalent;false
otherwise
-
parseLeft
public void parseLeft(java.lang.String jpqlFragment)
Parses the given JPQL fragment and update the left side of the compound expression.- Parameters:
jpqlFragment
- The portion of the query to become the left side of the compound expression
-
parseRight
public void parseRight(java.lang.String jpqlFragment)
Parses the given JPQL fragment and update the right side of the compound expression.- Parameters:
jpqlFragment
- The portion of the query to become the right side of the compound expression
-
setLeft
public void setLeft(StateObject leftStateObject)
Sets the leftStateObject
to become the given object.- Parameters:
leftStateObject
- TheStateObject
representing the left expression
-
setRight
public void setRight(StateObject rightStateObject)
Sets the rightStateObject
to become the given object.- Parameters:
rightStateObject
- TheStateObject
representing the right expression
-
toTextInternal
protected void toTextInternal(java.lang.Appendable writer) throws java.io.IOException
Prints out a string representation of thisStateObject
, which should not be used to define atrue
string representation of a JPQL query but should be used for debugging purposes.- Specified by:
toTextInternal
in classAbstractStateObject
- Parameters:
writer
- The writer used to print out the string representation- Throws:
java.io.IOException
- This should never happens, it is only required becauseAppendable
is used instead of any concrete class
-
-