Package adql.query
Class ClauseSelect
- All Implemented Interfaces:
ADQLObject,Iterable<SelectItem>
The SELECT clause of an ADQL query.
This ADQL clause is not only a list of ADQL items:
- The user can specify the maximum number of rows the query must return.
- He can also ask that all the returned rows are unique according to the first returned column.
-
Nested Class Summary
Nested classes/interfaces inherited from class adql.query.ADQLList
ADQLList.ADQLListIterator -
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionBuilds an empty SELECT clause.ClauseSelect(boolean distinctColumns) Builds an empty SELECT clause by specifying whether the returned rows are unique (regarding the first returned columns).ClauseSelect(boolean distinctColumns, int limit) Builds an empty SELECT clause.ClauseSelect(int limit) Builds an empty SELECT clause whose the returned rows must be limited to the given number.ClauseSelect(ClauseSelect toCopy) Builds a SELECT clause by copying the given one. -
Method Summary
Modifier and TypeMethodDescriptionvoidadd(int index, ADQLOperand operand) Adds an operand to this SELECT clause at the given position.booleanadd(ADQLOperand operand) Adds an operand to this SELECT clause.final booleanTells whether this clause imposes that returned rows are unique (regarding the first returned column).getCopy()Gets a (deep) copy of this ADQL object.final intgetLimit()Gets the maximum number of rows imposed by this SELECT clause.final booleanhasLimit()Indicates whether this SELECT clause imposes a maximum number of rows.searchByAlias(String alias) Gets the operand which is associated with the given alias (case sensitive).searchByAlias(String alias, boolean caseSensitive) Gets all the select items which are associated with the given alias.searchByIndex(int index) Gets the specified operand.set(int index, ADQLOperand operand) Replaces the specified operand by the given one.final voidsetDistinctColumns(boolean distinct) Changes the DISTINCT flag of this SELECT clause.final voidsetLimit(int limit) Changes the maximum number of rows this clause imposes.final voidSets no maximum number of rows (classic SELECT).toADQL()Gets the ADQL expression of this object.Methods inherited from class adql.query.ClauseADQL
getPossibleSeparators, getSeparatorMethods inherited from class adql.query.ADQLList
add, add, adqlIterator, clear, get, getFeatureDescription, getName, getPosition, isEmpty, iterator, remove, set, setPosition, sizeMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
ClauseSelect
public ClauseSelect()Builds an empty SELECT clause. -
ClauseSelect
public ClauseSelect(boolean distinctColumns) Builds an empty SELECT clause by specifying whether the returned rows are unique (regarding the first returned columns).- Parameters:
distinctColumns-truemeans unique rows (= SELECT DISTINCT),falseotherwise (= SELECT or = SELECT ALL).
-
ClauseSelect
public ClauseSelect(int limit) Builds an empty SELECT clause whose the returned rows must be limited to the given number.- Parameters:
limit- Maximum number of returned rows (= SELECT TOP limit).
-
ClauseSelect
public ClauseSelect(boolean distinctColumns, int limit) Builds an empty SELECT clause.- Parameters:
distinctColumns-truemeans unique rows (= SELECT DISTINCT),falseotherwise (= SELECT or = SELECT ALL).limit- Maximum number of returned rows (= SELECT TOP limit).
-
ClauseSelect
Builds a SELECT clause by copying the given one.- Parameters:
toCopy- The SELECT clause to copy.- Throws:
Exception- If there is an error during the copy.
-
-
Method Details
-
distinctColumns
public final boolean distinctColumns()Tells whether this clause imposes that returned rows are unique (regarding the first returned column).- Returns:
truefor SELECT DISTINCT,falsefor SELECT ALL.
-
setDistinctColumns
public final void setDistinctColumns(boolean distinct) Changes the DISTINCT flag of this SELECT clause.- Parameters:
distinct-truefor SELECT DISTINCT,falsefor SELECT ALL.
-
hasLimit
public final boolean hasLimit()Indicates whether this SELECT clause imposes a maximum number of rows.- Returns:
truethis clause has a TOP flag,falseotherwise.
-
getLimit
public final int getLimit()Gets the maximum number of rows imposed by this SELECT clause.- Returns:
- Maximum number of rows the query must return (SELECT TOP limit).
-
setNoLimit
public final void setNoLimit()Sets no maximum number of rows (classic SELECT). -
setLimit
public final void setLimit(int limit) Changes the maximum number of rows this clause imposes.- Parameters:
limit- The maximum number of returned rows (SELECT TOP limit).
-
add
Adds an operand to this SELECT clause.
IMPORTANT: The given operand will not be added directly! It will be encapsulated in a
SelectItemobject which will be then added to the SELECT clause.- Parameters:
operand- The operand to add.- Returns:
trueif the operand has been successfully added,falseotherwise.- Throws:
NullPointerException- If the given item is NULL.- See Also:
-
add
public void add(int index, ADQLOperand operand) throws NullPointerException, ArrayIndexOutOfBoundsException Adds an operand to this SELECT clause at the given position.IMPORTANT: The given operand will not be added directly! It will be encapsulated in a
SelectItemobject which will be then added to the SELECT clause.- Parameters:
index- The position at which the given operand must be added.operand- The operand to add.- Throws:
NullPointerException- If the given item is NULL.ArrayIndexOutOfBoundsException- If the index is out of range (index invalid input: '<' 0 || index > size()).- See Also:
-
set
public ADQLOperand set(int index, ADQLOperand operand) throws NullPointerException, ArrayIndexOutOfBoundsException Replaces the specified operand by the given one.IMPORTANT: The given operand will not be added directly! It will be encapsulated in a
SelectItemobject which will be then added to the SELECT clause.- Parameters:
index- The position of the SELECT item to replace.operand- The replacer of the specified SELECT item.- Returns:
- The replaced SELECT item.
- Throws:
NullPointerException- If the given item is NULL.ArrayIndexOutOfBoundsException- If the index is out of range (index invalid input: '<' 0 || index > size()).
-
searchByIndex
Gets the specified operand.- Parameters:
index- Index of the operand to retrieve.- Returns:
- The corresponding operand.
- Throws:
ArrayIndexOutOfBoundsException- If the index is out of range (index invalid input: '<' 0 || index > size()).
-
searchByAlias
Gets the operand which is associated with the given alias (case sensitive).- Parameters:
alias- Alias of the operand to retrieve.- Returns:
- The corresponding operand or NULL if none has been found.
- See Also:
-
searchByAlias
Gets all the select items which are associated with the given alias.- Parameters:
alias- Alias of the operand to retrieve.- Returns:
- All the corresponding select items.
-
getCopy
Description copied from interface:ADQLObjectGets a (deep) copy of this ADQL object.- Specified by:
getCopyin interfaceADQLObject- Overrides:
getCopyin classClauseADQL<SelectItem>- Returns:
- The copy of this ADQL object.
- Throws:
Exception- If there is any error during the copy.
-
toADQL
Description copied from interface:ADQLObjectGets the ADQL expression of this object.- Specified by:
toADQLin interfaceADQLObject- Overrides:
toADQLin classADQLList<SelectItem>- Returns:
- The corresponding ADQL expression.
-