Class AbstractConditionalClauseStateObject
- java.lang.Object
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject
-
- org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject
-
- All Implemented Interfaces:
StateObject
- Direct Known Subclasses:
HavingClauseStateObject
,WhenClauseStateObject
,WhereClauseStateObject
public abstract class AbstractConditionalClauseStateObject extends AbstractStateObject
Conditional expressions are composed of other conditional expressions, comparison operations, logical operations, path expressions that evaluate to boolean values, boolean literals, and boolean input parameters. Arithmetic expressions can be used in comparison expressions. Arithmetic expressions are composed of other arithmetic expressions, arithmetic operations, path expressions that evaluate to numeric values, numeric literals, and numeric input parameters. Arithmetic operations use numeric promotion. Standard bracketing () for ordering expression evaluation is supported.BNF:expression ::= identifier conditional_expression
- Version:
- 2.4
- See Also:
AbstractConditionalClause
- Author:
- Pascal Filion
- Since:
- 2.4
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
CONDITIONAL_STATE_OBJECT_PROPERTY
Notifies the conditional expression property has changed.
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractConditionalClauseStateObject(StateObject parent)
Creates a newAbstractConditionalClauseStateObject
.protected
AbstractConditionalClauseStateObject(StateObject parent, StateObject conditionalStateObject)
Creates a newAbstractConditionalClauseStateObject
.
-
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.AndExpressionStateObject
andParse(java.lang.String jpqlFragment)
Parses the given JPQL fragment as the right side of anAND
expression.IConditionalExpressionStateObjectBuilder
getBuilder()
Creates and returns a newIConditionalExpressionStateObjectBuilder
that can be used to programmatically create a conditional expression and once the expression is complete,IConditionalExpressionStateObjectBuilder.commit()
will push theStateObject
representation of that expression as this clause's conditional expression.StateObject
getConditional()
Returns the state object representing the composition of the conditional expressions.abstract java.lang.String
getIdentifier()
Returns the JPQL identifier of this clause.boolean
hasConditional()
Determines whether theStateObject
representing the conditional expression is present or not.boolean
isEquivalent(StateObject stateObject)
Determines whether the givenStateObject
is equivalent to this one, i.e. the information of bothStateObject
is the same.OrExpressionStateObject
orParse(java.lang.String jpqlFragment)
Parses the given JPQL fragment as the right side of anOR
expression.void
parse(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which represents a conditional expression, and creates theStateObject
.void
setConditional(StateObject conditionalStateObject)
Sets the givenStateObject
to be the conditional expression of this clause.protected boolean
shouldEncapsulateORExpression(StateObject stateObject)
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, getExpression, 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
-
CONDITIONAL_STATE_OBJECT_PROPERTY
public static final java.lang.String CONDITIONAL_STATE_OBJECT_PROPERTY
Notifies the conditional expression property has changed.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
AbstractConditionalClauseStateObject
protected AbstractConditionalClauseStateObject(StateObject parent)
Creates a newAbstractConditionalClauseStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
- Throws:
java.lang.NullPointerException
- The given parent cannot benull
-
AbstractConditionalClauseStateObject
protected AbstractConditionalClauseStateObject(StateObject parent, StateObject conditionalStateObject)
Creates a newAbstractConditionalClauseStateObject
.- Parameters:
parent
- The parent of this state object, which cannot benull
conditionalStateObject
- TheStateObject
representing the conditional expression- 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
-
andParse
public AndExpressionStateObject andParse(java.lang.String jpqlFragment)
Parses the given JPQL fragment as the right side of anAND
expression. The current conditional expression will become the left side of theAND
expression.- Parameters:
jpqlFragment
- The portion of the query representing the right side of theAND
expression- Returns:
- The newly created
AndExpressionStateObject
-
getBuilder
public IConditionalExpressionStateObjectBuilder getBuilder()
Creates and returns a newIConditionalExpressionStateObjectBuilder
that can be used to programmatically create a conditional expression and once the expression is complete,IConditionalExpressionStateObjectBuilder.commit()
will push theStateObject
representation of that expression as this clause's conditional expression.- Returns:
- A new builder that can be used to quickly create a conditional expression
-
getConditional
public StateObject getConditional()
Returns the state object representing the composition of the conditional expressions.- Returns:
- The actual conditional expression
-
getIdentifier
public abstract java.lang.String getIdentifier()
Returns the JPQL identifier of this clause.- Returns:
- The JPQL identifier of this conditional clause
-
hasConditional
public boolean hasConditional()
Determines whether theStateObject
representing the conditional expression is present or not.- Returns:
true
if the conditional expression is notnull
;false
otherwise
-
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
-
orParse
public OrExpressionStateObject orParse(java.lang.String jpqlFragment)
Parses the given JPQL fragment as the right side of anOR
expression. The current conditional expression will become the left side of theOR
expression.- Parameters:
jpqlFragment
- The portion of the query representing the right side of theOR
expression- Returns:
- The newly created
OrExpressionStateObject
-
parse
public void parse(java.lang.String jpqlFragment)
Parses the given JPQL fragment, which represents a conditional expression, and creates theStateObject
.- Parameters:
jpqlFragment
- The portion of the query representing a conditional expression
-
setConditional
public void setConditional(StateObject conditionalStateObject)
Sets the givenStateObject
to be the conditional expression of this clause.- Parameters:
conditionalStateObject
- The newStateObject
representing the conditional expression
-
shouldEncapsulateORExpression
protected boolean shouldEncapsulateORExpression(StateObject stateObject)
-
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
-
-