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

public Class WhenClauseStateObject

extends AbstractConditionalClauseStateObject
Class Inheritance
Annotations
@SuppressWarnings:nls, unused
Imports
java.io.IOException, java.util.List, org.eclipse.persistence.jpa.jpql.parser.InternalWhenClauseBNF, .ScalarExpressionBNF, .WhenClause, org.eclipse.persistence.jpa.jpql.tools.model.Problem

A WHEN predicate is used to calculate a condition and when it's true, its THEN will be executed.

BNF: when_clause ::= WHEN conditional_expression THEN scalar_expression

or

BNF: simple_when_clause ::= WHEN scalar_expression THEN scalar_expression

Author
Pascal Filion
Since
2.4
Version
2.4
See Also
WhenClause

Field Summary

Modifier and TypeField and Description
public static final String
THEN_STATE_OBJECT_PROPERTY

Notify the StateObject representing the scalar expression that follows the THEN identifier has changed.

private StateObject
thenStateObject

The StateObject representing the scalar expression that is following the THEN identifier.

Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject:
CONDITIONAL_STATE_OBJECT_PROPERTY

Constructor Summary

AccessConstructor and Description
public
WhenClauseStateObject(CaseExpressionStateObject
The parent of this state object, which cannot be null
parent
)

Creates a new WhenClauseStateObject.

public
WhenClauseStateObject(CaseExpressionStateObject
The parent of this state object
parent
,
StateObject
The StateObject representing the conditional expression that is following the WHEN identifier
whenStateObject
,
StateObject
The StateObject representing the scalar expression that is following the THEN identifier
thenStateObject
)

Creates a new WhenClauseStateObject.

public
WhenClauseStateObject(CaseExpressionStateObject
The parent of this state object
parent
,
String
The string representation of the WHEN clause to parse and to convert into a StateObject
whenJpqlFragment
,
String
The string representation of the THEN expression to parse and to convert into a StateObject
thenJpqlFragment
)

Creates a new WhenClauseStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
protected void
addChildren(List<StateObject>
The list used to store the children
children
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject.addChildren.

Adds the children of this StateObject to the given list.
protected void
addProblems(List<Problem>
The list to which the problems are added
problems
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addProblems.

Adds to the given list the problems that were found with the current state of this StateObject, which means there are validation issues.
public WhenClause
getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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
public CaseExpressionStateObject
public StateObject

Returns:

Either the StateObject representing the THEN expression or null if it's not defined
getThen
()

Returns the StateObject representing the scalar expression that is following the THEN identifier.

public boolean

Returns:

true the scalar expression exists; otherwise false
hasThen
()

Determines whether the StateObject representing the scalar expression is present.

public boolean
isEquivalent(StateObject
The StateObject to compare its content to this one
stateObject
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject.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
parseThen(String
The string representation of the THEN expression to parse and to convert into a StateObject
jpqlFragment
)

Parses the given JPQL fragment, which will represent the THEN expression.

public void
parseWhen(String
The string representation of the WHEN clause to parse and to convert into a StateObject
jpqlFragment
)

Parses the given JPQL fragment, which will represent the WHEN clause.

public void
setExpression(WhenClause
The parsed object representing a WHEN clause
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
setThen(StateObject
The StateObject representing the scalar expression
thenStateObject
)

Sets the scalar expression to be the given StateObject.

public void
toTextInternal(Appendable
The writer used to print out the string representation
writer
)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject.toTextInternal.

Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.
Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject:
andParsegetBuildergetConditionalhasConditionalorParseparsesetConditionalshouldEncapsulateORExpression

Field Detail

THEN_STATE_OBJECT_PROPERTYback to summary
public static final String THEN_STATE_OBJECT_PROPERTY

Notify the StateObject representing the scalar expression that follows the THEN identifier has changed.

thenStateObjectback to summary
private StateObject thenStateObject

The StateObject representing the scalar expression that is following the THEN identifier.

Constructor Detail

WhenClauseStateObjectback to summary
public WhenClauseStateObject(CaseExpressionStateObject parent)

Creates a new WhenClauseStateObject.

Parameters
parent:CaseExpressionStateObject

The parent of this state object, which cannot be null

Exceptions
NullPointerException:
The given parent cannot be null
WhenClauseStateObjectback to summary
public WhenClauseStateObject(CaseExpressionStateObject parent, StateObject whenStateObject, StateObject thenStateObject)

Creates a new WhenClauseStateObject.

Parameters
parent:CaseExpressionStateObject

The parent of this state object

whenStateObject:StateObject

The StateObject representing the conditional expression that is following the WHEN identifier

thenStateObject:StateObject

The StateObject representing the scalar expression that is following the THEN identifier

Exceptions
NullPointerException:
The given parent cannot be null
WhenClauseStateObjectback to summary
public WhenClauseStateObject(CaseExpressionStateObject parent, String whenJpqlFragment, String thenJpqlFragment)

Creates a new WhenClauseStateObject.

Parameters
parent:CaseExpressionStateObject

The parent of this state object

whenJpqlFragment:String

The string representation of the WHEN clause to parse and to convert into a StateObject

thenJpqlFragment:String

The string representation of the THEN 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
addChildrenback to summary
protected void addChildren(List<StateObject> children)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject.addChildren.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addChildren.

Adds the children of this StateObject to the given list.

Parameters
children:List<StateObject>

The list used to store the children

Annotations
@Override
addProblemsback to summary
protected void addProblems(List<Problem> problems)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addProblems.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.addProblems.

Adds to the given list the problems that were found with the current state of this StateObject, which means there are validation issues.

Parameters
problems:List<Problem>

The list to which the problems are added

Annotations
@Override
getExpressionback to summary
public WhenClause getExpression()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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:WhenClause

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.AbstractConditionalClauseStateObject.getIdentifier.

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

Returns the JPQL identifier of this clause.

Returns:String

The JPQL identifier of this conditional clause

Annotations
@Override
getParentback to summary
public CaseExpressionStateObject getParent()

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.getParent.

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

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

Returns the parent of this StateObject.

Returns:CaseExpressionStateObject

Returns the parent of this StateObject, which is null only when this is the root of the hierarchy

Annotations
@Override
getThenback to summary
public StateObject getThen()

Returns the StateObject representing the scalar expression that is following the THEN identifier.

Returns:StateObject

Either the StateObject representing the THEN expression or null if it's not defined

hasThenback to summary
public boolean hasThen()

Determines whether the StateObject representing the scalar expression is present.

Returns:boolean

true the scalar expression exists; otherwise false

isEquivalentback to summary
public boolean isEquivalent(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject.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
parseThenback to summary
public void parseThen(String jpqlFragment)

Parses the given JPQL fragment, which will represent the THEN expression. The JPQL fragment should not start with the identifier.

Parameters
jpqlFragment:String

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

parseWhenback to summary
public void parseWhen(String jpqlFragment)

Parses the given JPQL fragment, which will represent the WHEN clause. The JPQL fragment should not start with the identifier.

Parameters
jpqlFragment:String

The string representation of the WHEN clause to parse and to convert into a StateObject

setExpressionback to summary
public void setExpression(WhenClause 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:WhenClause

The parsed object representing a WHEN clause

setThenback to summary
public void setThen(StateObject thenStateObject)

Sets the scalar expression to be the given StateObject.

Parameters
thenStateObject:StateObject

The StateObject representing the scalar expression

toTextInternalback to summary
public void toTextInternal(Appendable writer) throws IOException

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractConditionalClauseStateObject.toTextInternal.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.toTextInternal.

Prints out a string representation of this StateObject, which should not be used to define a true string representation of a JPQL query but should be used for debugging purposes.

Parameters
writer:Appendable

The writer used to print out the string representation

Annotations
@Override
Exceptions
IOException:
This should never happens, it is only required because Appendable is used instead of any concrete class