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 class
ADQLList.ADQLListIterator
Lets iterating on all ADQL objects of the givenADQLList
.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(int index, T item)
Adds the given item (if not null) at the given position into this clause.boolean
add(T item)
Adds the given item (if not null) at the end of this clause.ADQLIterator
adqlIterator()
Gets an iterator on the intern ADQL objects.void
clear()
Clears this clause.T
get(int index)
Gets the specified ADQL item.abstract ADQLObject
getCopy()
Gets a (deep) copy of this ADQL object.java.lang.String
getName()
Gets the name of this object in ADQL.TextPosition
getPosition()
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.String
getSeparator(int index)
Gets the separator between the list items index-1 and index.boolean
isEmpty()
Tells whether this clause contains at least one ADQL item.java.util.Iterator<T>
iterator()
T
remove(int index)
Removes the specified ADQL item.T
set(int index, T item)
Replaces the specified ADQL item by the given one.void
setPosition(TextPosition position)
Sets the position at which thisADQLList
has been found in the original ADQL query string.int
size()
Gets the length of this clause.java.lang.String
toADQL()
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.ArrayIndexOutOfBoundsException
Adds 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:ADQLObject
Gets the name of this object in ADQL.- Specified by:
getName
in interfaceADQLObject
- Returns:
- The name of this ADQL object.
-
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)
Sets the position at which thisADQLList
has 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:ADQLObject
Gets the ADQL expression of this object.- Specified by:
toADQL
in interfaceADQLObject
- Returns:
- The corresponding ADQL expression.
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T extends ADQLObject>
-
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
-
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.ArrayIndexOutOfBoundsException
Gets 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: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.
-
-