Class ADQLQuery
- java.lang.Object
-
- adql.query.ADQLQuery
-
- All Implemented Interfaces:
ADQLObject
public class ADQLQuery extends java.lang.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)
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ADQLIterator
adqlIterator()
Gets an iterator on the intern ADQL objects.ADQLObject
getCopy()
Gets a (deep) copy of this ADQL object.FromContent
getFrom()
Gets the FROM clause of this query.ClauseADQL<ADQLColumn>
getGroupBy()
Gets the GROUP BY clause of this query.ClauseConstraints
getHaving()
Gets the HAVING clause of this query.java.lang.String
getName()
Gets the name of this object in ADQL.ClauseADQL<ADQLOrder>
getOrderBy()
Gets the ORDER BY clause of this query.TextPosition
getPosition()
Gets the position of this object/token in the ADQL query.DBColumn[]
getResultingColumns()
Gets the list of columns (database metadata) selected by this query.ClauseSelect
getSelect()
Gets the SELECT clause of this query.ClauseConstraints
getWhere()
Gets the WHERE clause of this query.void
reset()
Clear all the clauses.java.util.Iterator<ADQLObject>
search(ISearchHandler sHandler)
Lets searching ADQL objects into this ADQL query thanks to the given search handler.void
setFrom(FromContent newFrom)
Replaces its FROM clause by the given one.void
setGroupBy(ClauseADQL<ADQLColumn> newGroupBy)
Replaces its GROUP BY clause by the given one.void
setHaving(ClauseConstraints newHaving)
Replaces its HAVING clause by the given one.void
setOrderBy(ClauseADQL<ADQLOrder> newOrderBy)
Replaces its ORDER BY clause by the given one.void
setPosition(TextPosition position)
Set the position of thisADQLQuery
(or sub-query) inside the whole given ADQL query string.void
setSelect(ClauseSelect newSelect)
Replaces its SELECT clause by the given one.void
setWhere(ClauseConstraints newWhere)
Replaces its WHERE clause by the given one.java.lang.String
toADQL()
Gets the ADQL expression of this object.
-
-
-
Constructor Detail
-
ADQLQuery
public ADQLQuery()
Builds an empty ADQL query.
-
ADQLQuery
public ADQLQuery(ADQLQuery toCopy) throws java.lang.Exception
Builds an ADQL query by copying the given one.- Parameters:
toCopy
- The ADQL query to copy.- Throws:
java.lang.Exception
- If there is an error during the copy.
-
-
Method Detail
-
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 java.lang.NullPointerException
Replaces its SELECT clause by the given one.
note: the position of the query is erased.
- Parameters:
newSelect
- The new SELECT clause.- Throws:
java.lang.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 java.lang.NullPointerException
Replaces its FROM clause by the given one.
note: the position of the query is erased.
- Parameters:
newFrom
- The new FROM clause.- Throws:
java.lang.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 java.lang.NullPointerException
Replaces its WHERE clause by the given one.
note: the position of the query is erased.
- Parameters:
newWhere
- The new WHERE clause.- Throws:
java.lang.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 java.lang.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:
java.lang.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 java.lang.NullPointerException
Replaces its HAVING clause by the given one.
note: the position of the query is erased.
- Parameters:
newHaving
- The new HAVING clause.- Throws:
java.lang.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 java.lang.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:
java.lang.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 interfaceADQLObject
- 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 thisADQLQuery
(or sub-query) inside the whole given ADQL query string.- Parameters:
position
- New position of thisADQLQuery
.- Since:
- 1.4
-
getCopy
public ADQLObject getCopy() throws java.lang.Exception
Description copied from interface:ADQLObject
Gets a (deep) copy of this ADQL object.- Specified by:
getCopy
in interfaceADQLObject
- Returns:
- The copy of this ADQL object.
- Throws:
java.lang.Exception
- If there is any error during the copy.
-
getName
public java.lang.String getName()
Description copied from interface:ADQLObject
Gets the name of this object in ADQL.- Specified by:
getName
in interfaceADQLObject
- 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 java.util.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 interfaceADQLObject
- Returns:
- An ADQL objects iterator.
- See Also:
ADQLIterator
,ISearchHandler
-
toADQL
public java.lang.String toADQL()
Description copied from interface:ADQLObject
Gets the ADQL expression of this object.- Specified by:
toADQL
in interfaceADQLObject
- Returns:
- The corresponding ADQL expression.
-
-