Class Query

    • Constructor Summary

      Constructors 
      Constructor Description
      Query()
      Empty constructor.
    • Constructor Detail

      • Query

        public Query()
        Empty constructor.
    • Method Detail

      • setLimit

        public void setLimit​(int limit)
        Sets the LIMIT parameter for this query - note that this is only honoured in a subquery.
        Parameters:
        limit - the new limit parameter - the results will be truncated to this many rows
      • getLimit

        public int getLimit()
        Returns the LIMIT parameter for this query.
        Returns:
        the limit parameter
      • addFrom

        public void addFrom​(FromElement cls)
        Adds a FromElement to the FROM clause of this Query
        Specified by:
        addFrom in interface HasFromList
        Parameters:
        cls - the FromElement to be added
      • addFrom

        public Query addFrom​(FromElement cls,
                             java.lang.String alias)
        Adds a FromElement to the FROM clause of this Query
        Parameters:
        cls - the FromElement to be added
        alias - the alias for this FromElement
        Returns:
        the updated Query
      • deleteFrom

        public Query deleteFrom​(FromElement cls)
        Remove a FromElement from the FROM clause
        Parameters:
        cls - the FromElement to remove
        Returns:
        the updated Query
      • getFrom

        public java.util.Set<FromElement> getFrom()
        Returns all FromElements in the FROM clause
        Returns:
        set of FromElements
      • setConstraint

        public void setConstraint​(Constraint constraint)
        Constrain this Query using either a single constraint or a set of constraints
        Specified by:
        setConstraint in interface Queryable
        Parameters:
        constraint - the constraint or constraint set
      • getConstraint

        public Constraint getConstraint()
        Get the current constraint on this Query
        Specified by:
        getConstraint in interface Queryable
        Returns:
        the constraint
      • addToGroupBy

        public Query addToGroupBy​(QueryNode node)
        Add a QueryNode to the GROUP BY clause of this Query
        Parameters:
        node - the node to add
        Returns:
        the updated Query
      • deleteFromGroupBy

        public Query deleteFromGroupBy​(QueryNode node)
        Remove a QueryNode from the GROUP BY clause
        Parameters:
        node - the node to remove
        Returns:
        the updated Query
      • getGroupBy

        public java.util.Set<QueryNode> getGroupBy()
        Gets the GROUP BY clause of this Query
        Returns:
        the set of GROUP BY nodes
      • addToOrderBy

        public Query addToOrderBy​(QueryOrderable node)
        Add a QueryOrderable to the ORDER BY clause of this Query
        Parameters:
        node - the node to add
        Returns:
        the updated Query
      • addToOrderBy

        public Query addToOrderBy​(QueryOrderable node,
                                  java.lang.String direction)
        Add a QueryOrderable to the ORDER BY clause of this Query
        Parameters:
        node - the node to add
        direction - ascending or descending
        Returns:
        the updated Query
      • deleteFromOrderBy

        public Query deleteFromOrderBy​(QueryOrderable node)
        Remove a QueryOrderable from the ORDER BY clause
        Parameters:
        node - the node to remove
        Returns:
        the updated Query
      • clearOrderBy

        public void clearOrderBy()
        Clears the ORDER BY clause of this Query
      • getOrderBy

        public java.util.List<QueryOrderable> getOrderBy()
        Gets the ORDER BY clause of this Query
        Returns:
        the List of ORDER BY nodes
      • getEffectiveOrderBy

        public java.util.List<java.lang.Object> getEffectiveOrderBy()
        Gets the effective ORDER BY clause of this Query, such as may be used to create SQL.
        Returns:
        a List of ORDER BY nodes
      • addToSelect

        public void addToSelect​(QuerySelectable node)
        Add a QuerySelectable to the SELECT clause of this Query
        Specified by:
        addToSelect in interface Queryable
        Parameters:
        node - the QuerySelectable to add
      • addToSelect

        public Query addToSelect​(QuerySelectable node,
                                 java.lang.String alias)
        Add a QuerySelectable to the SELECT clause of this Query
        Parameters:
        node - the QuerySelectable to add
        alias - the alias for this FromElement
        Returns:
        the updated Query
      • deleteFromSelect

        public Query deleteFromSelect​(QuerySelectable node)
        Remove a QuerySelectable from the SELECT clause
        Parameters:
        node - the QuerySelectable to remove
        Returns:
        the updated Query
      • getSelect

        public java.util.List<QuerySelectable> getSelect()
        Gets the SELECT list
        Specified by:
        getSelect in interface Queryable
        Returns:
        the (unmodifiable) list
      • clearSelect

        public void clearSelect()
        Clears the SELECT list
      • isDistinct

        public boolean isDistinct()
        Get the value of the distinct property
        Returns:
        the value of distinct
      • setDistinct

        public void setDistinct​(boolean distinct)
        Set the value of the distinct property, which determines whether duplicates are permitted in the results returned by this Query
        Parameters:
        distinct - the value of distinct
      • getAliases

        public java.util.Map<java.lang.Object,​java.lang.String> getAliases()
        Returns the map of QuerySelectables and FromElements to String aliases
        Returns:
        the map
      • getReverseAliases

        public java.util.Map<java.lang.String,​java.lang.Object> getReverseAliases()
        Returns the map of String aliases to QuerySelectables and FromElements
        Returns:
        the map
      • toString

        public java.lang.String toString()
        Returns a string representation of this Query object
        Overrides:
        toString in class java.lang.Object
        Returns:
        a String representation
      • getIqlQuery

        public IqlQuery getIqlQuery()
        Returns an IqlQuery object representing this query, that may have been cached.
        Returns:
        an IqlQuery object
      • alias

        public void alias​(java.lang.Object obj,
                          java.lang.String alias)
        Set an alias for an element in the Query.
        Parameters:
        obj - the element to alias
        alias - the alias to give