Class SelectStatementStateObject

    • Field Detail

      • ORDER_BY_CLAUSE_PROPERTY

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

      • SelectStatementStateObject

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

      • addOrderByClause

        public OrderByClauseStateObject addOrderByClause()
        Adds the ORDER BY clause. The clause is not added if it's already present.
        Returns:
        The state object representing the ORDER BY clause
      • addOrderByClause

        public OrderByClauseStateObject addOrderByClause​(java.lang.String jpqlFragment)
        Adds the ORDER BY clause and parses the given JPQL fragment, which should represent one or many ordering items. The clause is not added if it's already present.
        Parameters:
        jpqlFragment - The fragment of the JPQL to parse that represents the ordering items, the fragment cannot start with ORDER BY
        Returns:
        The OrderByClauseStateObject
      • addSelectItem

        public void addSelectItem​(StateObject stateObject)
        Adds the given StateObject as a select item.
        Parameters:
        stateObject - The StateObject representing a select expression
      • addSelectItem

        public StateObject addSelectItem​(java.lang.String path)
        Adds the given path as a select item, which can either be an identification variable or a state-field path expression.
        Parameters:
        path - The select expression to parse as a select item
        Returns:
        The StateObject encapsulating the given path
      • addSelectItem

        public ResultVariableStateObject addSelectItem​(java.lang.String jpqlFragment,
                                                       java.lang.String resultVariable)
        Adds the given expression as a select item.
        Parameters:
        jpqlFragment - The select expression to parse as a select item
        resultVariable - The result variable identifying the select expression
        Returns:
        The newly created ResultVariableStateObject
      • addSelectItemAs

        public ResultVariableStateObject addSelectItemAs​(java.lang.String jpqlFragment,
                                                         java.lang.String resultVariable)
        Adds the given expression as a select item.
        Parameters:
        jpqlFragment - The portion of a JPQL query that represents a select expression
        resultVariable - The result variable identifying the select expression
        Returns:
        The newly created ResultVariableStateObject
      • getOrderByClause

        public OrderByClauseStateObject getOrderByClause()
        Returns the state object representing the ORDER BY clause.
        Returns:
        Either the actual state object representing the ORDER BY clause or null if it's not present
      • hasOrderByClause

        public boolean hasOrderByClause()
        Returns the state object representing the ORDER BY clause.
        Returns:
        true if the ORDER BY clause is present; false otherwise
      • removeOrderByClause

        public void removeOrderByClause()
        Removes the ORDER BY clause.
      • setExpression

        public void setExpression​(SelectStatement 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 a SELECT statement
      • toggleOrderByClause

        public void toggleOrderByClause()
        Either adds or removes the ORDER BY 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.
        Overrides:
        toTextInternal in class AbstractSelectStatementStateObject
        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