Package adql.query

Class ADQLQuery

java.lang.Object
adql.query.ADQLQuery
All Implemented Interfaces:
ADQLObject

public class ADQLQuery extends Object implements ADQLObject

Object representation of an ADQL query or sub-query.

The resulting object of the ADQLParser is an object of this class.

Version:
1.4 (11/2017)
Author:
Grégory Mantelet (CDS;ARI)
  • Constructor Details

    • ADQLQuery

      public ADQLQuery()
      Builds an empty ADQL query.
    • ADQLQuery

      public ADQLQuery(ADQLQuery toCopy) throws Exception
      Builds an ADQL query by copying the given one.
      Parameters:
      toCopy - The ADQL query to copy.
      Throws:
      Exception - If there is an error during the copy.
  • Method Details

    • reset

      public void reset()
      Clear all the clauses.
    • getSelect

      public final ClauseSelect getSelect()
      Gets the SELECT clause of this query.
      Returns:
      Its SELECT clause.
    • setSelect

      public void setSelect(ClauseSelect newSelect) throws NullPointerException

      Replaces its SELECT clause by the given one.

      note: the position of the query is erased.

      Parameters:
      newSelect - The new SELECT clause.
      Throws:
      NullPointerException - If the given SELECT clause is null.
    • getFrom

      public final FromContent getFrom()
      Gets the FROM clause of this query.
      Returns:
      Its FROM clause.
    • setFrom

      public void setFrom(FromContent newFrom) throws NullPointerException

      Replaces its FROM clause by the given one.

      note: the position of the query is erased.

      Parameters:
      newFrom - The new FROM clause.
      Throws:
      NullPointerException - If the given FROM clause is null.
    • getWhere

      public final ClauseConstraints getWhere()
      Gets the WHERE clause of this query.
      Returns:
      Its WHERE clause.
    • setWhere

      public void setWhere(ClauseConstraints newWhere) throws NullPointerException

      Replaces its WHERE clause by the given one.

      note: the position of the query is erased.

      Parameters:
      newWhere - The new WHERE clause.
      Throws:
      NullPointerException - If the given WHERE clause is null.
    • getGroupBy

      public final ClauseADQL<ADQLColumn> getGroupBy()
      Gets the GROUP BY clause of this query.
      Returns:
      Its GROUP BY clause.
    • setGroupBy

      public void setGroupBy(ClauseADQL<ADQLColumn> newGroupBy) throws NullPointerException

      Replaces its GROUP BY clause by the given one.

      note: the position of the query is erased.

      Parameters:
      newGroupBy - The new GROUP BY clause.
      Throws:
      NullPointerException - If the given GROUP BY clause is null.
    • getHaving

      public final ClauseConstraints getHaving()
      Gets the HAVING clause of this query.
      Returns:
      Its HAVING clause.
    • setHaving

      public void setHaving(ClauseConstraints newHaving) throws NullPointerException

      Replaces its HAVING clause by the given one.

      note: the position of the query is erased.

      Parameters:
      newHaving - The new HAVING clause.
      Throws:
      NullPointerException - If the given HAVING clause is null.
    • getOrderBy

      public final ClauseADQL<ADQLOrder> getOrderBy()
      Gets the ORDER BY clause of this query.
      Returns:
      Its ORDER BY clause.
    • setOrderBy

      public void setOrderBy(ClauseADQL<ADQLOrder> newOrderBy) throws NullPointerException

      Replaces its ORDER BY clause by the given one.

      note: the position of the query is erased.

      Parameters:
      newOrderBy - The new ORDER BY clause.
      Throws:
      NullPointerException - If the given ORDER BY clause is null.
    • getPosition

      public final TextPosition getPosition()
      Description copied from interface: ADQLObject

      Gets the position of this object/token in the ADQL query.

      By default, no position should be set.

      Specified by:
      getPosition in interface ADQLObject
      Returns:
      Position of this ADQL item in the ADQL query, or NULL if not written originally in the query (for example, if added afterwards.
    • setPosition

      public final void setPosition(TextPosition position)
      Set the position of this ADQLQuery (or sub-query) inside the whole given ADQL query string.
      Parameters:
      position - New position of this ADQLQuery.
      Since:
      1.4
    • getCopy

      public ADQLObject getCopy() throws Exception
      Description copied from interface: ADQLObject
      Gets a (deep) copy of this ADQL object.
      Specified by:
      getCopy in interface ADQLObject
      Returns:
      The copy of this ADQL object.
      Throws:
      Exception - If there is any error during the copy.
    • getName

      public String getName()
      Description copied from interface: ADQLObject
      Gets the name of this object in ADQL.
      Specified by:
      getName in interface ADQLObject
      Returns:
      The name of this ADQL object.
    • getResultingColumns

      public DBColumn[] getResultingColumns()

      Gets the list of columns (database metadata) selected by this query.

      Note: The list is generated on the fly !

      Returns:
      Selected columns metadata.
    • search

      public Iterator<ADQLObject> search(ISearchHandler sHandler)
      Lets searching ADQL objects into this ADQL query thanks to the given search handler.
      Parameters:
      sHandler - A search handler.
      Returns:
      An iterator on all ADQL objects found.
    • adqlIterator

      public ADQLIterator adqlIterator()
      Description copied from interface: ADQLObject

      Gets an iterator on the intern ADQL objects.

      Note:The returned iterator is particularly used by a ISearchHandler extension to browse a whole ADQL tree.

      Specified by:
      adqlIterator in interface ADQLObject
      Returns:
      An ADQL objects iterator.
      See Also:
    • toADQL

      public String toADQL()
      Description copied from interface: ADQLObject
      Gets the ADQL expression of this object.
      Specified by:
      toADQL in interface ADQLObject
      Returns:
      The corresponding ADQL expression.