Package adql.query
Class ADQLList<T extends ADQLObject>
- java.lang.Object
-
- adql.query.ADQLList<T>
-
- All Implemented Interfaces:
ADQLObject,java.lang.Iterable<T>
- Direct Known Subclasses:
ClauseADQL,Concatenation
public abstract class ADQLList<T extends ADQLObject> extends java.lang.Object implements ADQLObject, java.lang.Iterable<T>
Represents a list of ADQL items.
Since it is a list, it is possible to add, remove, modify and iterate on a such object.
- Version:
- 1.4 (06/2015)
- Author:
- Grégory Mantelet (CDS;ARI)
- See Also:
ClauseADQL,ClauseConstraints,Operation,Concatenation
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classADQLList.ADQLListIteratorLets iterating on all ADQL objects of the givenADQLList.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidadd(int index, T item)Adds the given item (if not null) at the given position into this clause.booleanadd(T item)Adds the given item (if not null) at the end of this clause.ADQLIteratoradqlIterator()Gets an iterator on the intern ADQL objects.voidclear()Clears this clause.Tget(int index)Gets the specified ADQL item.abstract ADQLObjectgetCopy()Gets a (deep) copy of this ADQL object.java.lang.StringgetName()Gets the name of this object in ADQL.TextPositiongetPosition()Gets the position of this object/token in the ADQL query.abstract java.lang.String[]getPossibleSeparators()Gets the list of all possible separators for thisADQLList.abstract java.lang.StringgetSeparator(int index)Gets the separator between the list items index-1 and index.booleanisEmpty()Tells whether this clause contains at least one ADQL item.java.util.Iterator<T>iterator()Tremove(int index)Removes the specified ADQL item.Tset(int index, T item)Replaces the specified ADQL item by the given one.voidsetPosition(TextPosition position)Sets the position at which thisADQLListhas been found in the original ADQL query string.intsize()Gets the length of this clause.java.lang.StringtoADQL()Gets the ADQL expression of this object.
-
-
-
Method Detail
-
add
public boolean add(T item) throws java.lang.NullPointerException
Adds the given item (if not null) at the end of this clause.- Parameters:
item- The ADQL item to add to this clause.- Returns:
- true if the given item has been successfully added, false otherwise.
- Throws:
java.lang.NullPointerException- If the given item is null.
-
add
public void add(int index, T item) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsExceptionAdds the given item (if not null) at the given position into this clause.- Parameters:
index- Position at which the given item must be added.item- ADQL item to add to this clause.- Throws:
java.lang.NullPointerException- If the given item is null.java.lang.ArrayIndexOutOfBoundsException- If the index is out of range (index < 0 || index > size()).
-
set
public T set(int index, T item) throws java.lang.NullPointerException, java.lang.ArrayIndexOutOfBoundsException
Replaces the specified ADQL item by the given one.- Parameters:
index- Position of the item to replace.item- Replacer of the specified ADQL item.- Returns:
- The replaced ADQL item.
- Throws:
java.lang.NullPointerException- If the given item is null.java.lang.ArrayIndexOutOfBoundsException- If the index is out of range (index < 0 || index > size()).
-
get
public T get(int index) throws java.lang.ArrayIndexOutOfBoundsException
Gets the specified ADQL item.- Parameters:
index- Index of the ADQL item to retrieve.- Returns:
- The corresponding ADQL item.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- If the index is out of range (index < 0 || index > size()).
-
remove
public T remove(int index) throws java.lang.ArrayIndexOutOfBoundsException
Removes the specified ADQL item.- Parameters:
index- Index of the ADQL item to remove.- Returns:
- The removed ADQL item.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- If the index is out of range (index < 0 || index > size()).
-
clear
public void clear()
Clears this clause.
-
size
public int size()
Gets the length of this clause.- Returns:
- The number of ADQL items contained into this clause.
-
isEmpty
public boolean isEmpty()
Tells whether this clause contains at least one ADQL item.- Returns:
- true if this clause is empty, false otherwise.
-
getName
public java.lang.String getName()
Description copied from interface:ADQLObjectGets the name of this object in ADQL.- Specified by:
getNamein interfaceADQLObject- Returns:
- The name of this ADQL object.
-
getPosition
public final TextPosition getPosition()
Description copied from interface:ADQLObjectGets the position of this object/token in the ADQL query.
By default, no position should be set.
- Specified by:
getPositionin 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)
Sets the position at which thisADQLListhas been found in the original ADQL query string.- Parameters:
position- Position of thisADQLList.- Since:
- 1.4
-
toADQL
public java.lang.String toADQL()
Description copied from interface:ADQLObjectGets the ADQL expression of this object.- Specified by:
toADQLin interfaceADQLObject- Returns:
- The corresponding ADQL expression.
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<T extends ADQLObject>
-
adqlIterator
public ADQLIterator adqlIterator()
Description copied from interface:ADQLObjectGets an iterator on the intern ADQL objects.
Note:The returned iterator is particularly used by a
ISearchHandlerextension to browse a whole ADQL tree.- Specified by:
adqlIteratorin interfaceADQLObject- Returns:
- An ADQL objects iterator.
- See Also:
ADQLIterator,ISearchHandler
-
getPossibleSeparators
public abstract java.lang.String[] getPossibleSeparators()
Gets the list of all possible separators for thisADQLList.- Returns:
- Possible separators.
-
getSeparator
public abstract java.lang.String getSeparator(int index) throws java.lang.ArrayIndexOutOfBoundsExceptionGets the separator between the list items index-1 and index.- Parameters:
index- Index of the right list item.- Returns:
- The corresponding separator.
- Throws:
java.lang.ArrayIndexOutOfBoundsException- If the index is less or equal than 0, or is greater or equal thansize().
-
getCopy
public abstract ADQLObject getCopy() throws java.lang.Exception
Description copied from interface:ADQLObjectGets a (deep) copy of this ADQL object.- Specified by:
getCopyin interfaceADQLObject- Returns:
- The copy of this ADQL object.
- Throws:
java.lang.Exception- If there is any error during the copy.
-
-