public class CollectionMemberDeclarationStateObject extends AbstractStateObject implements VariableDeclarationStateObject
collection_member_declaration ranges over
values of a collection obtained by navigation using a path expression. Such a path expression
represents a navigation involving the association-fields of an entity abstract schema type.
Because a path expression can be based on another path expression, the navigation can use the
association-fields of related entities. An identification variable of a collection member
declaration is declared using a special operator, the reserved identifier IN.
The argument to the IN operator is a collection-valued path expression. The
path expression evaluates to a collection type specified as a result of navigation to a
collection-valued association-field of an entity abstract schema type. The syntax for declaring a
collection member identification variable is as follows:
collection_member_declaration ::= IN(collection_valued_path_expression) [AS] identification_variableor
derived_collection_member_declaration ::= IN superquery_identification_variable.{single_valued_object_field.}*collection_valued_fieldFromClauseStateObject,
CollectionMemberDeclaration| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
AS_PROPERTY
Notifies the visibility of the
AS identifier has changed. |
| Constructor and Description |
|---|
CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent)
Creates a new
CollectionMemberDeclarationStateObject. |
CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent,
java.util.ListIterator<java.lang.String> paths,
boolean as,
java.lang.String identificationVariable)
Creates a new
CollectionMemberDeclarationStateObject. |
CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent,
java.util.ListIterator<java.lang.String> paths,
java.lang.String identificationVariable)
Creates a new
CollectionMemberDeclarationStateObject. |
CollectionMemberDeclarationStateObject(SimpleFromClauseStateObject parent,
java.lang.String collectionValuedPath)
Creates a new
CollectionMemberDeclarationStateObject. |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(StateObjectVisitor visitor)
Visits this
StateObject by the given visitor. |
CollectionMemberDeclarationStateObject |
addAs()
Makes sure the
AS identifier is specified. |
protected void |
addChildren(java.util.List<StateObject> children)
Adds the children of this
StateObject to the given list. |
CollectionValuedPathExpressionStateObject |
getCollectionValuedPath()
Returns the model object representing the collection-valued association-field
of an entity abstract schema type.
|
CollectionMemberDeclaration |
getExpression()
Returns the actual parsed object if this
StateObject representation of the JPQL query
was created by parsing an existing JPQL query. |
IdentificationVariableStateObject |
getIdentificationVariable()
Returns the model object representing an identification variable
evaluating to a collection-valued association-field of an entity abstract
schema type.
|
IManagedType |
getManagedType(StateObject stateObject)
Returns the
IManagedType for the given identification variable. |
AbstractFromClauseStateObject |
getParent()
Returns the parent of this
StateObject. |
boolean |
hasAs()
Determines whether the
AS identifier is used or not. |
boolean |
hasIdentificationVariable()
Determines whether an identification variable was defined.
|
ListIterable<IdentificationVariableStateObject> |
identificationVariables()
Returns the
IdentificationVariableStateObject that are used by this state object. |
protected void |
initialize()
Initializes this state object.
|
boolean |
isDerived()
Determines whether this collection member declaration is used as a derived collection-valued
path 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 |
removeAs()
Makes sure the
AS identifier is not specified. |
void |
setAs(boolean as)
Sets whether the
AS identifier is used or not. |
void |
setDerived(boolean derived)
Sets whether this collection member declaration is used as a derived collection-valued path
expression.
|
void |
setExpression(CollectionMemberDeclaration 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 |
setIdentificationVariable(java.lang.String identificationVariable)
Sets the new identification variable that will range over the collection-valued path.
|
void |
setPath(java.lang.String path)
Changes the path expression with the list of segments, the identification variable will also
be updated with the first segment.
|
void |
setPaths(java.util.List<java.lang.String> paths)
Changes the path expression with the list of segments, the identification variable will also
be updated with the first segment.
|
void |
setPaths(java.util.ListIterator<java.lang.String> paths)
Changes the path expression with the list of segments, the identification variable will also
be updated with the first segment.
|
void |
setPaths(java.lang.String... paths)
Changes the path expression with the list of segments, the identification variable will also
be updated with the first segment.
|
void |
toggleAs()
Toggles the usage of the
AS identifier. |
protected void |
toTextInternal(java.lang.Appendable writer)
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. |
acceptUnknownVisitor, acceptUnknownVisitor, addProblems, addPropertyChangeListener, areEquivalent, buildProblem, buildProblem, buildStateObject, buildStateObjects, checkParent, children, decorate, equals, findIdentificationVariable, firePropertyChanged, getChangeSupport, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, getType, getType, getTypeHelper, getTypeRepository, hashCode, isDecorated, parent, parent, parent, removePropertyChangeListener, setExpression, setParent, toString, toString, toStringInternal, toStringItems, toTextclone, finalize, getClass, notify, notifyAll, wait, wait, waitaddPropertyChangeListener, children, decorate, findIdentificationVariable, getDeclaration, getDecorator, getGrammar, getManagedTypeProvider, getQueryBuilder, getRoot, isDecorated, removePropertyChangeListener, setParent, toString, toTextpublic static final java.lang.String AS_PROPERTY
AS identifier has changed.public CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent)
CollectionMemberDeclarationStateObject.parent - The parent of this state object, which cannot be nulljava.lang.NullPointerException - The given parent cannot be nullpublic CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent, java.util.ListIterator<java.lang.String> paths, boolean as, java.lang.String identificationVariable)
CollectionMemberDeclarationStateObject.parent - The parent of this state object, which cannot be nullpaths - The segments that represent the collection-valued pathas - Determine whether the AS identifier is used or notidentificationVariable - The identification variable declaring the collection-valued pathjava.lang.NullPointerException - The given parent cannot be nullpublic CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent, java.util.ListIterator<java.lang.String> paths, java.lang.String identificationVariable)
CollectionMemberDeclarationStateObject.parent - The parent of this state object, which cannot be nullpaths - The segments that represent the collection-valued pathidentificationVariable - The identification variable declaring the collection-valued pathjava.lang.NullPointerException - The given parent cannot be nullpublic CollectionMemberDeclarationStateObject(SimpleFromClauseStateObject parent, java.lang.String collectionValuedPath)
CollectionMemberDeclarationStateObject.parent - The parent of this state object, which cannot be nullcollectionValuedPath - The derived collection-valued path expressionjava.lang.NullPointerException - The given parent cannot be nullpublic void accept(StateObjectVisitor visitor)
StateObject by the given visitor.accept in interface StateObjectvisitor - The visitor to visit this objectpublic CollectionMemberDeclarationStateObject addAs()
AS identifier is specified.protected void addChildren(java.util.List<StateObject> children)
StateObject to the given list.addChildren in class AbstractStateObjectchildren - The list used to store the childrenpublic CollectionValuedPathExpressionStateObject getCollectionValuedPath()
public CollectionMemberDeclaration getExpression()
StateObject representation of the JPQL query
was created by parsing an existing JPQL query.getExpression in interface StateObjectgetExpression in class AbstractStateObjectStateObject
or null when the JPQL query is manually created (i.e. not from a string)public IdentificationVariableStateObject getIdentificationVariable()
public IManagedType getManagedType(StateObject stateObject)
IManagedType for the given identification variable. The search does not
traverse up the query hierarchy if this declaration is for a subquery.
SELECT e FROM Department d JOIN KEY(d.employees).addresses a
In the above query, the managed type associated with the identification variable:
getManagedType in interface VariableDeclarationStateObjectstateObject - The StateObject that should be an simple identification variable or
an encapsulated identification variable with the identifier KEY or
VALUEIManagedType representing the domain object declared by the given
identification variablepublic AbstractFromClauseStateObject getParent()
StateObject.getParent in interface StateObjectgetParent in class AbstractStateObjectStateObject, which is null only when
this is the root of the hierarchypublic boolean hasAs()
AS identifier is used or not.true if the AS identifier is part
of the expression; false otherwisepublic boolean hasIdentificationVariable()
true if an identification variable is defined; false otherwisepublic ListIterable<IdentificationVariableStateObject> identificationVariables()
IdentificationVariableStateObject that are used by this state object. It
is possible more than one declaration exists, like a range variable declaration has also joins
and join fetches.identificationVariables in interface VariableDeclarationStateObjectIdentificationVariableStateObjectprotected void initialize()
initialize in class AbstractStateObjectpublic boolean isDerived()
true if this collection member declaration is used as this form:
"IN collection_valued_path_expression" in a subquery; false
if it's used as this form: IN(collection_valued_path_expression)
[AS] identification_variable" in a top-level or subquery queriespublic boolean isEquivalent(StateObject stateObject)
StateObject is equivalent to this one, i.e. the
information of both StateObject is the same.isEquivalent in interface StateObjectisEquivalent in class AbstractStateObjectstateObject - The StateObject to compare its content to this onetrue if both object are equivalent; false otherwisepublic void removeAs()
AS identifier is not specified.public void setAs(boolean as)
AS identifier is used or not.as - true if the AS identifier is part of the expression;
false otherwisepublic void setDerived(boolean derived)
derived - true if this collection member declaration is used as this form:
"IN collection_valued_path_expression" in a subquery; false
if it's used as this form: IN(collection_valued_path_expression)
[AS] identification_variable" in a top-level or subquery queriespublic void setExpression(CollectionMemberDeclaration expression)
parsed object object, which
should only be done when this object is instantiated during the conversion of a parsed JPQL
query into StateObjects.expression - The parsed object representing an IN
expressionpublic void setIdentificationVariable(java.lang.String identificationVariable)
identificationVariable - The new identification variablepublic void setPath(java.lang.String path)
path - The new path expressionpublic void setPaths(java.util.List<java.lang.String> paths)
paths - The new path expressionpublic void setPaths(java.util.ListIterator<java.lang.String> paths)
paths - The new path expressionpublic void setPaths(java.lang.String... paths)
paths - The new path expressionpublic void toggleAs()
AS identifier.protected void toTextInternal(java.lang.Appendable writer)
throws java.io.IOException
StateObject, which should not be used to
define a true string representation of a JPQL query but should be used for
debugging purposes.toTextInternal in class AbstractStateObjectwriter - The writer used to print out the string representationjava.io.IOException - This should never happens, it is only required because Appendable
is used instead of any concrete class