Package adql.db

## Class DBCommonColumn

- java.lang.Object
- - adql.db.DBCommonColumn

- All Implemented Interfaces:
    `DBColumn`

      public class DBCommonColumn
      extends java.lang.Object
      implements DBColumn

  This is a special column which exists only after a NATURAL JOIN or a JOIN ... USING between two tables. It lets unify several columns of the joined tables in a single column. Thus, the writer of an ADQL query can use the column name without table prefix (since after the join there will be only one) or with a prefix table of the joined tables. The list of all covered tables is stored in this object and can be extended in case of several JOINs.
  Since:
    1.2
  Version:
    1.3 (05/2015)
  Author:
    Grégory Mantelet (ARI) - gmantele@ari.uni-heidelberg.de

- - ### Field Summary

    Fields
    Modifier and Type | Field | Description
    --- | --- | ---
    `protected DBColumn` | `generalColumnDesc` |
    `protected java.util.ArrayList<DBTable>` | `lstCoveredTables` |

  - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DBCommonColumn​(DBColumn leftCol, DBColumn rightCol)` | Create a column which merges both of the given columns.
    `DBCommonColumn​(DBCommonColumn toCopy, java.lang.String dbName, java.lang.String adqlName)` | Constructor by copy.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `protected void` | `addCoveredTable​(DBTable table)` | Add a table that this common column must cover from now.
    `DBColumn` | `copy​(java.lang.String dbName, java.lang.String adqlName, DBTable dbTable)` | WARNING: This copy function does not make a real copy of this DBCommonColumn ! It returns a modified copy of the general column description it contains.
    `java.lang.String` | `getADQLName()` | Gets the name of this column (without any prefix and double-quotes).
    `java.util.Iterator<DBTable>` | `getCoveredTables()` | Get an iterator over the list of all tables covered by this common column.
    `DBType` | `getDatatype()` | Get the type of this column (as closed as possible from the "database" type).
    `java.lang.String` | `getDBName()` | Gets the name of this column in the "database".
    `DBTable` | `getTable()` | Gets the table which contains this `DBColumn`.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### generalColumnDesc

          protected DBColumn generalColumnDesc

    - #### lstCoveredTables

          protected java.util.ArrayList<DBTable> lstCoveredTables

  - ### Constructor Detail

    - #### DBCommonColumn

          public DBCommonColumn​(DBColumn leftCol,
                                DBColumn rightCol)
                         throws UnresolvedJoinException

      Create a column which merges both of the given columns. This special `DBColumn` implementation is not associated with one table, and can be listed in a `DBTable` ONLY IF the latter is the result of a sub-query (see `ADQLQuery.getResultingColumns()`). A column resulting from a tables join is common only to the joined tables. That's why a list of all tables covered by this column is created or update at each merge. It can be accessed thanks to `getCoveredTables()`. Note: In the case one or both of the columns to join are `DBCommonColumn`, the list of their covered tables are also merged.
      Parameters:
        `leftCol` - Column of the left join table. May be a `DBCommonColumn`.
        `rightCol` - Column of the right join table. May be a `DBCommonColumn`.
      Throws:
        `UnresolvedJoinException` - If the type of the two given columns are not roughly (just testing numeric, string or geometry) compatible.

    - #### DBCommonColumn

          public DBCommonColumn​(DBCommonColumn toCopy,
                                java.lang.String dbName,
                                java.lang.String adqlName)

      Constructor by copy. It returns a copy of this instance of `DBCommonColumn`. Note: The list of covered tables is NOT deeply copied!
      Parameters:
        `toCopy` - The `DBCommonColumn` to copy.
        `dbName` - The new DB name of this `DBCommonColumn`.
        `adqlName` - The new ADQL name of this `DBCommonColumn`.

  - ### Method Detail

    - #### getADQLName

          public final java.lang.String getADQLName()

      Description copied from interface: `DBColumn`
      Gets the name of this column (without any prefix and double-quotes).
      Specified by:
        `getADQLName` in interface `DBColumn`
      Returns:
        Its ADQL name.

    - #### getDBName

          public final java.lang.String getDBName()

      Description copied from interface: `DBColumn`
      Gets the name of this column in the "database".
      Specified by:
        `getDBName` in interface `DBColumn`
      Returns:
        Its DB name.

    - #### getDatatype

          public final DBType getDatatype()

      Description copied from interface: `DBColumn`

      Get the type of this column (as closed as possible from the "database" type).

      Note: The returned type should be as closed as possible from a type listed by the IVOA in the TAP protocol description into the section UPLOAD.

      Specified by:
        `getDatatype` in interface `DBColumn`
      Returns:
        Its type.

    - #### getTable

          public final DBTable getTable()

      Description copied from interface: `DBColumn`
      Gets the table which contains this `DBColumn`.
      Specified by:
        `getTable` in interface `DBColumn`
      Returns:
        Its table or null if no table is specified.

    - #### getCoveredTables

          public final java.util.Iterator<DBTable> getCoveredTables()

      Get an iterator over the list of all tables covered by this common column.
      Returns:
        Iterator over all covered tables.

    - #### addCoveredTable

          protected void addCoveredTable​(DBTable table)

      Add a table that this common column must cover from now. Warning: no unicity check is never done !
      Parameters:
        `table` - Table to add in the covered tables list.

    - #### copy

          public DBColumn copy​(java.lang.String dbName,
                               java.lang.String adqlName,
                               DBTable dbTable)

      WARNING: This copy function does not make a real copy of this DBCommonColumn ! It returns a modified copy of the general column description it contains. Note: To make a real copy of this DBCommonColumn use the Constructor by copy `DBCommonColumn(DBCommonColumn, String, String)`.
      Specified by:
        `copy` in interface `DBColumn`
      Parameters:
        `dbName` - Its new DB name.
        `adqlName` - Its new ADQL name.
        `dbTable` - Its new DBTable
      Returns:
        A modified copy of the general column description this common column represents.
      See Also:
        `DBColumn.copy(java.lang.String, java.lang.String, adql.db.DBTable)`