Class AbstractSelectStatementStateObject

    • Field Detail

      • GROUP_BY_CLAUSE_PROPERTY

        public static final java.lang.String GROUP_BY_CLAUSE_PROPERTY
        Notify the state object representing the GROUP BY clause has changed.
        See Also:
        Constant Field Values
      • HAVING_CLAUSE_PROPERTY

        public static final java.lang.String HAVING_CLAUSE_PROPERTY
        Notify the state object representing the HAVING clause has changed.
        See Also:
        Constant Field Values
      • WHERE_CLAUSE_PROPERTY

        public static final java.lang.String WHERE_CLAUSE_PROPERTY
        Notify the state object representing the WHERE clause has changed.
        See Also:
        Constant Field Values
    • Constructor Detail

      • AbstractSelectStatementStateObject

        protected AbstractSelectStatementStateObject​(StateObject parent)
        Creates a new AbstractSelectStatementStateObject.
        Parameters:
        parent - The parent of this state object, which cannot be null
        Throws:
        java.lang.NullPointerException - The given parent cannot be null
    • Method Detail

      • addCollectionDeclaration

        public CollectionMemberDeclarationStateObject addCollectionDeclaration​(java.lang.String collectionValuedPath,
                                                                               java.lang.String identificationVariable)
        Adds a new collection declaration to the FROM clause.
        Parameters:
        collectionValuedPath - The collection-valued path expression
        identificationVariable - The variable defining the collection-valued path expression
        Returns:
        The CollectionMemberDeclarationStateObject representing the collection declaration
      • addGroupByClause

        public GroupByClauseStateObject addGroupByClause​(java.lang.String jpqlFragment)
        Adds the GROUP BY clause and parses the given JPQL fragment. The clause is not added if it's already present.
        Parameters:
        jpqlFragment - The fragment of the JPQL to parse that represents the group by items, the fragment cannot start with GROUP BY
        Returns:
        The GroupByClauseStateObject
      • addHavingClause

        public HavingClauseStateObject addHavingClause​(java.lang.String jpqlFragment)
        Adds the HAVING clause and parses the given JPQL fragment. The clause is not added if it's already present.
        Parameters:
        jpqlFragment - The fragment of the JPQL to parse that represents the conditional expression, the fragment cannot start with HAVING
        Returns:
        The HavingClauseStateObject
      • addRangeDeclaration

        public IdentificationVariableDeclarationStateObject addRangeDeclaration​(IEntity entity,
                                                                                java.lang.String identificationVariable)
        Adds to this select statement a new range variable declaration.
        Parameters:
        entity - The external form of the entity to add to the declaration list
        identificationVariable - The unique identifier identifying the given IEntity
        Returns:
        The StateObject representing the new range variable declaration
      • addRangeDeclaration

        public IdentificationVariableDeclarationStateObject addRangeDeclaration​(java.lang.String entityName,
                                                                                java.lang.String identificationVariable)
        Adds to this select statement a new range variable declaration.
        Parameters:
        entityName - The name of the entity
        identificationVariable - The unique identifier identifying the entity
        Returns:
        The StateObject representing the range variable declaration
      • addWhereClause

        public WhereClauseStateObject addWhereClause​(java.lang.String jpqlFragment)
        Adds the WHERE clause and parses the given JPQL fragment. The clause is not added if it's already present.
        Parameters:
        jpqlFragment - The fragment of the JPQL to parse that represents the conditional expression, the fragment cannot start with WHERE
        Returns:
        The WhereClauseStateObject
      • getDeclaration

        public DeclarationStateObject getDeclaration()
        Returns the declaration clause which defines the domain of the query by declaring identification variables.
        Specified by:
        getDeclaration in interface StateObject
        Overrides:
        getDeclaration in class AbstractStateObject
        Returns:
        The declaration clause of which this StateObject is a child; i.e. either the top-level declaration if this is part of the top query or the sub-level declaration if this is part of a subquery
      • getFromClause

        public AbstractFromClauseStateObject getFromClause()
        Returns the state object representing the FROM clause.
        Returns:
        The state object representing the FROM clause, which is never null
      • getGroupByClause

        public GroupByClauseStateObject getGroupByClause()
        Returns the state object representing the GROUP BY clause.
        Returns:
        Either the actual state object representing the GROUP BY clause or null if it's not present
      • getHavingClause

        public HavingClauseStateObject getHavingClause()
        Returns the state object representing the HAVING clause.
        Returns:
        Either the actual state object representing the HAVING clause or null if it's not present
      • getSelectClause

        public AbstractSelectClauseStateObject getSelectClause()
        Returns the state object representing the SELECT clause.
        Returns:
        Either the actual state object representing the SELECT clause, which is never null
      • getWhereClause

        public WhereClauseStateObject getWhereClause()
        Returns the state object representing the WHERE clause.
        Returns:
        Either the actual state object representing the WHERE clause or the null state object since null is never returned
      • hasGroupByClause

        public boolean hasGroupByClause()
        Returns the state object representing the GROUP BY clause.
        Returns:
        Either the actual state object representing the GROUP BY clause or null if it's not present
      • hasHavingClause

        public boolean hasHavingClause()
        Returns the state object representing the HAVING clause.
        Returns:
        Either the actual state object representing the HAVING clause or null if it's not present
      • hasWhereClause

        public boolean hasWhereClause()
        Returns the state object representing the WHERE clause.
        Returns:
        Either the actual state object representing the WHERE clause or null if it's not present
      • parseSelect

        public void parseSelect​(java.lang.String jpqlFragment)
        Parses the given JPQL fragment and create the select item. For the top-level query, the fragment can contain several select items but for a subquery, it can represent only one.
        Parameters:
        jpqlFragment - The portion of the query representing one or several select items
      • removeGroupByClause

        public void removeGroupByClause()
        Removes the GROUP BY clause.
      • removeHavingClause

        public void removeHavingClause()
        Removes the HAVING clause.
      • removeWhereClause

        public void removeWhereClause()
        Removes the WHERE clause.
      • toggleGroupByClause

        public void toggleGroupByClause()
        Either adds or removes the state object representing the GROUP BY clause.
      • toggleHavingClause

        public void toggleHavingClause()
        Either adds or removes the state object representing the HAVING clause.
      • toggleWhereClause

        public void toggleWhereClause()
        Either adds or removes the state object representing the WHERE clause.
      • 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