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

public Class CollectionMemberDeclarationStateObject

extends AbstractStateObject
implements VariableDeclarationStateObject
Class Inheritance
All Implemented Interfaces
org.eclipse.persistence.jpa.jpql.tools.model.query.VariableDeclarationStateObject, org.eclipse.persistence.jpa.jpql.tools.model.query.StateObject
Annotations
@SuppressWarnings:nls, unused
Imports
java.io.IOException, java.util.List, .ListIterator, org.eclipse.persistence.jpa.jpql.parser.CollectionMemberDeclaration, org.eclipse.persistence.jpa.jpql.tools.spi.IManagedType, org.eclipse.persistence.jpa.jpql.tools.utility.iterable.SingleElementListIterable, org.eclipse.persistence.jpa.jpql.utility.iterable.ListIterable

An identification variable declared by a 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:

BNF: collection_member_declaration ::= IN(collection_valued_path_expression) [AS] identification_variable

or

BNF: derived_collection_member_declaration ::= IN superquery_identification_variable.{single_valued_object_field.}*collection_valued_field

Author
Pascal Filion
Since
2.4
Version
2.5
See Also
FromClauseStateObject, CollectionMemberDeclaration

Field Summary

Modifier and TypeField and Description
private boolean
as

Flag used to determine if the AS identifier is used or not.

public static final String
AS_PROPERTY

Notifies the visibility of the AS identifier has changed.

private CollectionValuedPathExpressionStateObject
collectionValuedPath

The model object representing the collection-valued association-field of an entity abstract schema type.

private boolean
derived

Determines whether this collection member declaration is used as a deriving collection-valued path expression.

private IdentificationVariableStateObject
identificationVariable

The model object representing an identification variable evaluating to a collection-valued association-field of an entity abstract schema type.

Constructor Summary

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

Creates a new CollectionMemberDeclarationStateObject.

public
CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject
The parent of this state object, which cannot be null
parent
,
ListIterator<String>
The segments that represent the collection-valued path
paths
,
boolean
Determine whether the AS identifier is used or not
as
,
String
The identification variable declaring the collection-valued path
identificationVariable
)

Creates a new CollectionMemberDeclarationStateObject.

public
CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject
The parent of this state object, which cannot be null
parent
,
ListIterator<String>
The segments that represent the collection-valued path
paths
,
String
The identification variable declaring the collection-valued path
identificationVariable
)

Creates a new CollectionMemberDeclarationStateObject.

public
CollectionMemberDeclarationStateObject(SimpleFromClauseStateObject
The parent of this state object, which cannot be null
parent
,
String
The derived collection-valued path expression
collectionValuedPath
)

Creates a new CollectionMemberDeclarationStateObject.

Method Summary

Modifier and TypeMethod and Description
public void
public CollectionMemberDeclarationStateObject

Returns:

This object
addAs
()

Makes sure the AS identifier is specified.

protected void
addChildren(List<StateObject>
The list used to store the children
children
)

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

Adds the children of this StateObject to the given list.
public CollectionValuedPathExpressionStateObject

Returns:

The collection-valued association-field of an entity abstract schema type
getCollectionValuedPath
()

Returns the model object representing the collection-valued association-field of an entity abstract schema type.

public CollectionMemberDeclaration
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 IdentificationVariableStateObject

Returns:

The identification variable portion of this declaration
getIdentificationVariable
()

Returns the model object representing an identification variable evaluating to a collection-valued association-field of an entity abstract schema type.

public IManagedType
getManagedType(StateObject
The StateObject that should be an simple identification variable or an encapsulated identification variable with the identifier KEY or VALUE
stateObject
)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.VariableDeclarationStateObject.getManagedType.

Returns the IManagedType for the given identification variable.
public AbstractFromClauseStateObject
public boolean

Returns:

true if the AS identifier is part of the expression; false otherwise
hasAs
()

Determines whether the AS identifier is used or not.

public boolean

Returns:

true if an identification variable is defined; false otherwise
hasIdentificationVariable
()

Determines whether an identification variable was defined.

public ListIterable<IdentificationVariableStateObject>
protected void
public boolean

Returns:

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 queries
isDerived
()

Determines whether this collection member declaration is used as a derived collection-valued path expression.

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

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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
removeAs()

Makes sure the AS identifier is not specified.

public void
setAs(boolean
true if the AS identifier is part of the expression; false otherwise
as
)

Sets whether the AS identifier is used or not.

public void
setDerived(boolean
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 queries
derived
)

Sets whether this collection member declaration is used as a derived collection-valued path expression.

public void
setExpression(CollectionMemberDeclaration
The parsed object representing an IN 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
setIdentificationVariable(String
The new identification variable
identificationVariable
)

Sets the new identification variable that will range over the collection-valued path.

public void
setPath(String
The new path expression
path
)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

public void
setPaths(List<String>
The new path expression
paths
)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

public void
setPaths(ListIterator<String>
The new path expression
paths
)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

public void
setPaths(String...
The new path expression
paths
)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

public void
toggleAs()

Toggles the usage of the AS identifier.

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

Implements abstract 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.
Inherited from org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject:
acceptUnknownVisitoracceptUnknownVisitoraddProblemsaddPropertyChangeListenerareEquivalentbuildProblembuildProblembuildStateObjectbuildStateObjectscheckParentchildrendecorateequalsfindIdentificationVariablefirePropertyChangedgetChangeSupportgetDeclarationgetDecoratorgetGrammargetManagedTypeProvidergetQueryBuildergetRootgetTypegetTypegetTypeHelpergetTypeRepositoryhashCodeisDecoratedparentparentparentremovePropertyChangeListenersetExpressionsetParenttoStringtoStringtoStringInternaltoStringItemstoText

Field Detail

asback to summary
private boolean as

Flag used to determine if the AS identifier is used or not.

AS_PROPERTYback to summary
public static final String AS_PROPERTY

Notifies the visibility of the AS identifier has changed.

collectionValuedPathback to summary
private CollectionValuedPathExpressionStateObject collectionValuedPath

The model object representing the collection-valued association-field of an entity abstract schema type.

derivedback to summary
private boolean derived

Determines whether this collection member declaration is used as a deriving collection-valued path expression.

identificationVariableback to summary
private IdentificationVariableStateObject identificationVariable

The model object representing an identification variable evaluating to a collection-valued association-field of an entity abstract schema type.

Constructor Detail

CollectionMemberDeclarationStateObjectback to summary
public CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent)

Creates a new CollectionMemberDeclarationStateObject.

Parameters
parent:AbstractFromClauseStateObject

The parent of this state object, which cannot be null

Exceptions
NullPointerException:
The given parent cannot be null
CollectionMemberDeclarationStateObjectback to summary
public CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent, ListIterator<String> paths, boolean as, String identificationVariable)

Creates a new CollectionMemberDeclarationStateObject.

Parameters
parent:AbstractFromClauseStateObject

The parent of this state object, which cannot be null

paths:ListIterator<String>

The segments that represent the collection-valued path

as:boolean

Determine whether the AS identifier is used or not

identificationVariable:String

The identification variable declaring the collection-valued path

Exceptions
NullPointerException:
The given parent cannot be null
CollectionMemberDeclarationStateObjectback to summary
public CollectionMemberDeclarationStateObject(AbstractFromClauseStateObject parent, ListIterator<String> paths, String identificationVariable)

Creates a new CollectionMemberDeclarationStateObject.

Parameters
parent:AbstractFromClauseStateObject

The parent of this state object, which cannot be null

paths:ListIterator<String>

The segments that represent the collection-valued path

identificationVariable:String

The identification variable declaring the collection-valued path

Exceptions
NullPointerException:
The given parent cannot be null
CollectionMemberDeclarationStateObjectback to summary
public CollectionMemberDeclarationStateObject(SimpleFromClauseStateObject parent, String collectionValuedPath)

Creates a new CollectionMemberDeclarationStateObject.

Parameters
parent:SimpleFromClauseStateObject

The parent of this state object, which cannot be null

collectionValuedPath:String

The derived collection-valued path expression

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
addAsback to summary
public CollectionMemberDeclarationStateObject addAs()

Makes sure the AS identifier is specified.

Returns:CollectionMemberDeclarationStateObject

This object

addChildrenback to summary
protected void addChildren(List<StateObject> children)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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
getCollectionValuedPathback to summary
public CollectionValuedPathExpressionStateObject getCollectionValuedPath()

Returns the model object representing the collection-valued association-field of an entity abstract schema type.

Returns:CollectionValuedPathExpressionStateObject

The collection-valued association-field of an entity abstract schema type

getExpressionback to summary
public CollectionMemberDeclaration 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:CollectionMemberDeclaration

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
getIdentificationVariableback to summary
public IdentificationVariableStateObject getIdentificationVariable()

Returns the model object representing an identification variable evaluating to a collection-valued association-field of an entity abstract schema type.

Returns:IdentificationVariableStateObject

The identification variable portion of this declaration

getManagedTypeback to summary
public IManagedType getManagedType(StateObject stateObject)

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.VariableDeclarationStateObject.getManagedType.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.VariableDeclarationStateObject.getManagedType.

Returns the 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:
  • d is "Department"
  • a is "Address"
Parameters
stateObject:StateObject

The StateObject that should be an simple identification variable or an encapsulated identification variable with the identifier KEY or VALUE

Returns:IManagedType

The IManagedType representing the domain object declared by the given identification variable

Annotations
@Override
getParentback to summary
public AbstractFromClauseStateObject 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:AbstractFromClauseStateObject

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

Annotations
@Override
hasAsback to summary
public boolean hasAs()

Determines whether the AS identifier is used or not.

Returns:boolean

true if the AS identifier is part of the expression; false otherwise

hasIdentificationVariableback to summary
public boolean hasIdentificationVariable()

Determines whether an identification variable was defined.

Returns:boolean

true if an identification variable is defined; false otherwise

identificationVariablesback to summary
public ListIterable<IdentificationVariableStateObject> identificationVariables()

Implements org.eclipse.persistence.jpa.jpql.tools.model.query.VariableDeclarationStateObject.identificationVariables.

Doc from org.eclipse.persistence.jpa.jpql.tools.model.query.VariableDeclarationStateObject.identificationVariables.

Returns the 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.

Returns:ListIterable<IdentificationVariableStateObject>

The list of IdentificationVariableStateObject

Annotations
@Override
initializeback to summary
protected void initialize()

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

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

Initializes this state object.

Annotations
@Override
isDerivedback to summary
public boolean isDerived()

Determines whether this collection member declaration is used as a derived collection-valued path expression.

Returns:boolean

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 queries

isEquivalentback to summary
public boolean isEquivalent(StateObject stateObject)

Overrides org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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
removeAsback to summary
public void removeAs()

Makes sure the AS identifier is not specified.

setAsback to summary
public void setAs(boolean as)

Sets whether the AS identifier is used or not.

Parameters
as:boolean

true if the AS identifier is part of the expression; false otherwise

setDerivedback to summary
public void setDerived(boolean derived)

Sets whether this collection member declaration is used as a derived collection-valued path expression.

Parameters
derived:boolean

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 queries

setExpressionback to summary
public 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.

Parameters
expression:CollectionMemberDeclaration

The parsed object representing an IN expression

setIdentificationVariableback to summary
public void setIdentificationVariable(String identificationVariable)

Sets the new identification variable that will range over the collection-valued path.

Parameters
identificationVariable:String

The new identification variable

setPathback to summary
public void setPath(String path)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters
path:String

The new path expression

setPathsback to summary
public void setPaths(List<String> paths)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters
paths:List<String>

The new path expression

setPathsback to summary
public void setPaths(ListIterator<String> paths)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters
paths:ListIterator<String>

The new path expression

setPathsback to summary
public void setPaths(String... paths)

Changes the path expression with the list of segments, the identification variable will also be updated with the first segment.

Parameters
paths:String[]

The new path expression

toggleAsback to summary
public void toggleAs()

Toggles the usage of the AS identifier.

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

Implements abstract org.eclipse.persistence.jpa.jpql.tools.model.query.AbstractStateObject.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