Class CollectionMemberDeclarationStateObject

  • All Implemented Interfaces:
    StateObject, VariableDeclarationStateObject

    public class CollectionMemberDeclarationStateObject
    extends AbstractStateObject
    implements VariableDeclarationStateObject
    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

    Version:
    2.5
    See Also:
    FromClauseStateObject, CollectionMemberDeclaration
    Author:
    Pascal Filion
    Since:
    2.4
    • Field Detail

      • AS_PROPERTY

        public static final java.lang.String AS_PROPERTY
        Notifies the visibility of the AS identifier has changed.
        See Also:
        Constant Field Values
    • Constructor Detail

      • CollectionMemberDeclarationStateObject

        public CollectionMemberDeclarationStateObject​(AbstractFromClauseStateObject parent)
        Creates a new CollectionMemberDeclarationStateObject.
        Parameters:
        parent - The parent of this state object, which cannot be null
        Throws:
        java.lang.NullPointerException - The given parent cannot be null
      • CollectionMemberDeclarationStateObject

        public CollectionMemberDeclarationStateObject​(AbstractFromClauseStateObject parent,
                                                      java.util.ListIterator<java.lang.String> paths,
                                                      boolean as,
                                                      java.lang.String identificationVariable)
        Creates a new CollectionMemberDeclarationStateObject.
        Parameters:
        parent - The parent of this state object, which cannot be null
        paths - The segments that represent the collection-valued path
        as - Determine whether the AS identifier is used or not
        identificationVariable - The identification variable declaring the collection-valued path
        Throws:
        java.lang.NullPointerException - The given parent cannot be null
      • CollectionMemberDeclarationStateObject

        public CollectionMemberDeclarationStateObject​(AbstractFromClauseStateObject parent,
                                                      java.util.ListIterator<java.lang.String> paths,
                                                      java.lang.String identificationVariable)
        Creates a new CollectionMemberDeclarationStateObject.
        Parameters:
        parent - The parent of this state object, which cannot be null
        paths - The segments that represent the collection-valued path
        identificationVariable - The identification variable declaring the collection-valued path
        Throws:
        java.lang.NullPointerException - The given parent cannot be null
      • CollectionMemberDeclarationStateObject

        public CollectionMemberDeclarationStateObject​(SimpleFromClauseStateObject parent,
                                                      java.lang.String collectionValuedPath)
        Creates a new CollectionMemberDeclarationStateObject.
        Parameters:
        parent - The parent of this state object, which cannot be null
        collectionValuedPath - The derived collection-valued path expression
        Throws:
        java.lang.NullPointerException - The given parent cannot be null
    • Method Detail

      • getCollectionValuedPath

        public CollectionValuedPathExpressionStateObject getCollectionValuedPath()
        Returns the model object representing the collection-valued association-field of an entity abstract schema type.
        Returns:
        The collection-valued association-field of an entity abstract schema type
      • getIdentificationVariable

        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:
        The identification variable portion of this declaration
      • getManagedType

        public IManagedType getManagedType​(StateObject stateObject)
        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"
        Specified by:
        getManagedType in interface VariableDeclarationStateObject
        Parameters:
        stateObject - The StateObject that should be an simple identification variable or an encapsulated identification variable with the identifier KEY or VALUE
        Returns:
        The IManagedType representing the domain object declared by the given identification variable
      • hasAs

        public boolean hasAs()
        Determines whether the AS identifier is used or not.
        Returns:
        true if the AS identifier is part of the expression; false otherwise
      • hasIdentificationVariable

        public boolean hasIdentificationVariable()
        Determines whether an identification variable was defined.
        Returns:
        true if an identification variable is defined; false otherwise
      • isDerived

        public boolean isDerived()
        Determines whether this collection member declaration is used as a derived collection-valued path expression.
        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
      • removeAs

        public void removeAs()
        Makes sure the AS identifier is not specified.
      • setAs

        public void setAs​(boolean as)
        Sets whether the AS identifier is used or not.
        Parameters:
        as - true if the AS identifier is part of the expression; false otherwise
      • setDerived

        public void setDerived​(boolean derived)
        Sets whether this collection member declaration is used as a derived collection-valued path expression.
        Parameters:
        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 queries
      • setExpression

        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 - The parsed object representing an IN expression
      • setIdentificationVariable

        public void setIdentificationVariable​(java.lang.String identificationVariable)
        Sets the new identification variable that will range over the collection-valued path.
        Parameters:
        identificationVariable - The new identification variable
      • setPath

        public 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.
        Parameters:
        path - The new path expression
      • setPaths

        public 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.
        Parameters:
        paths - The new path expression
      • setPaths

        public 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.
        Parameters:
        paths - The new path expression
      • setPaths

        public 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.
        Parameters:
        paths - The new path expression
      • toggleAs

        public void toggleAs()
        Toggles the usage of the AS identifier.
      • toTextInternal

        protected void toTextInternal​(java.lang.Appendable writer)
                               throws java.io.IOException
        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.
        Specified by:
        toTextInternal in class AbstractStateObject
        Parameters:
        writer - The writer used to print out the string representation
        Throws:
        java.io.IOException - This should never happens, it is only required because Appendable is used instead of any concrete class