Package adql.query
Class ColumnReference
- java.lang.Object
-
- adql.query.ColumnReference
-
- All Implemented Interfaces:
ADQLObject
- Direct Known Subclasses:
ADQLOrder
public class ColumnReference extends java.lang.Object implements ADQLObject
Represents a reference to a selected column either by an index or by a non-qualified column name/alias.- Version:
- 01/2012
- Author:
- Grégory Mantelet (CDS)
- See Also:
ADQLOrder
-
-
Constructor Summary
Constructors Constructor Description ColumnReference(int index)
Builds a column reference with an index of a selected column.ColumnReference(ColumnReference toCopy)
Builds a column reference by copying the given one.ColumnReference(java.lang.String colName)
Builds a column reference with a name/alias of a selected column.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ADQLIterator
adqlIterator()
Gets an iterator on the intern ADQL objects.ADQLTable
getAdqlTable()
Gets theADQLTable
from which this column is supposed to come.int
getColumnIndex()
Gets the index of the referenced column.java.lang.String
getColumnName()
Gets the name/alias of the referenced column.ADQLObject
getCopy()
Gets a (deep) copy of this ADQL object.DBColumn
getDBLink()
Gets the correspondingDBColumn
.java.lang.String
getName()
Gets the name of this object in ADQL.TextPosition
getPosition()
Gets the position in the original ADQL query string.boolean
isCaseSensitive()
Tells whether the column reference on a column name/alias is case sensitive.boolean
isIndex()
Tells whether the column is referenced by its index or by its name/alias.void
setAdqlTable(ADQLTable adqlTable)
Sets theADQLTable
from which this column is supposed to come.void
setCaseSensitive(boolean sensitive)
Sets the case sensitivity on the column name/alias.boolean
setColumnIndex(int index)
Sets the index of the referenced column.boolean
setColumnName(java.lang.String name)
Sets the name/alias of the referenced column.void
setDBLink(DBColumn dbLink)
Sets theDBColumn
corresponding to thisADQLColumn
.void
setPosition(TextPosition pos)
Sets the position at which thisColumnReference
has been found in the original ADQL query string.java.lang.String
toADQL()
Gets the ADQL expression of this object.
-
-
-
Constructor Detail
-
ColumnReference
public ColumnReference(int index) throws java.lang.ArrayIndexOutOfBoundsException
Builds a column reference with an index of a selected column.- Parameters:
index
- Index of a selected column (from 1).- Throws:
java.lang.ArrayIndexOutOfBoundsException
- If the given index is less or equal 0.
-
ColumnReference
public ColumnReference(java.lang.String colName) throws java.lang.NullPointerException
Builds a column reference with a name/alias of a selected column.- Parameters:
colName
- A column name/alias.- Throws:
java.lang.NullPointerException
- If the given name is null or is an empty string.
-
ColumnReference
public ColumnReference(ColumnReference toCopy)
Builds a column reference by copying the given one.- Parameters:
toCopy
- The column reference to copy.
-
-
Method Detail
-
getPosition
public final TextPosition getPosition()
Gets the position in the original ADQL query string.- Specified by:
getPosition
in interfaceADQLObject
- Returns:
- The position of this
ColumnReference
.
-
setPosition
public void setPosition(TextPosition pos)
Sets the position at which thisColumnReference
has been found in the original ADQL query string.- Parameters:
pos
- Position of thisColumnReference
.
-
getColumnIndex
public final int getColumnIndex()
Gets the index of the referenced column.- Returns:
- The index of the referenced column or -1 if this column reference has been made with a column name/alias.
-
setColumnIndex
public final boolean setColumnIndex(int index)
Sets the index of the referenced column.- Parameters:
index
- The index of the referenced column (must be > 0).- Returns:
- true if the column referenced has been updated, false otherwise (if index <= 0).
-
isIndex
public final boolean isIndex()
Tells whether the column is referenced by its index or by its name/alias.- Returns:
- true if by index, false if by name/alias.
-
getColumnName
public final java.lang.String getColumnName()
Gets the name/alias of the referenced column.- Returns:
- The referenced column's name/alias or null if this column reference has been made with a column index.
-
setColumnName
public final boolean setColumnName(java.lang.String name)
Sets the name/alias of the referenced column.- Parameters:
name
- The referenced column's name/alias (must be different from null and from an empty string).- Returns:
- true if the column reference has been updated, false otherwise (if name is null or is an empty string).
-
isCaseSensitive
public final boolean isCaseSensitive()
Tells whether the column reference on a column name/alias is case sensitive.- Returns:
- true if the column name/alias is case sensitive, false otherwise.
-
setCaseSensitive
public final void setCaseSensitive(boolean sensitive)
Sets the case sensitivity on the column name/alias.- Parameters:
sensitive
- true to make case sensitive the column name/alias, false otherwise.
-
getDBLink
public final DBColumn getDBLink()
Gets the correspondingDBColumn
.- Returns:
- The corresponding
DBColumn
ifgetColumnName()
is a column name (not an alias), null otherwise.
-
setDBLink
public final void setDBLink(DBColumn dbLink)
Sets the
DBColumn
corresponding to thisADQLColumn
.By default, this field is automatically filled by
DBChecker
.- Parameters:
dbLink
- Its correspondingDBColumn
ifgetColumnName()
is a column name (not an alias), null otherwise.
-
getAdqlTable
public final ADQLTable getAdqlTable()
Gets theADQLTable
from which this column is supposed to come.- Returns:
- Its source table if
getColumnName()
is a column name (not an alias), otherwise null.
-
setAdqlTable
public final void setAdqlTable(ADQLTable adqlTable)
Sets the
ADQLTable
from which this column is supposed to come.By default, this field is automatically filled by
DBChecker
whenDBChecker.check(adql.query.ADQLQuery)
is called.- Parameters:
adqlTable
- Its source table ifgetColumnName()
is a column name (not an alias), null otherwise.
-
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.
-
adqlIterator
public final 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.
-
-