Package adql.db

Class DBTableAlias

All Implemented Interfaces:
DBTable, Iterable<DBColumn>

public final class DBTableAlias extends DBIdentifier implements DBTable
This DBTable wraps another DBTable with a different ADQL and DB name.

This wrapper aims to represent in the metadata the aliasing of a table. This table should not be part of any schema, in ADQL but also in SQL...it is just an alias of an existing table.

All columns of the origin table are completely copied into this DBTable thanks to DBColumn.copy(String, String, DBTable), with the same ADQL and DB name but a different parent table (this one is used of the original one).

Note: The origin table is still available thanks to the function getOriginTable().

Since:
1.4
  • Field Details

    • columns

      protected final Map<String,DBColumn> columns
    • originTable

      protected final DBTable originTable
      Wrapped table.
  • Constructor Details

    • DBTableAlias

      public DBTableAlias(DBTable originTable, String tableAlias)
      Wrap the given table under the given ADQL/DB name.
      Parameters:
      originTable - The table to wrap/alias.
      tableAlias - The alias name.
  • Method Details

    • getOriginTable

      public DBTable getOriginTable()
      Get the aliased/wrapped table.
      Returns:
      The aliased table.
    • iterator

      public Iterator<DBColumn> iterator()
      Specified by:
      iterator in interface Iterable<DBColumn>
    • getADQLSchemaName

      public String getADQLSchemaName()
      Description copied from interface: DBTable
      Gets the ADQL name of the schema which contains this table.

      Warning! Same rules as DBTable.getADQLName().

      Specified by:
      getADQLSchemaName in interface DBTable
      Returns:
      ADQL name of its schema.
    • getDBSchemaName

      public String getDBSchemaName()
      Description copied from interface: DBTable
      Gets the DB name of the schema which contains this table.

      Warning! Same rules as DBTable.getDBName().

      Specified by:
      getDBSchemaName in interface DBTable
      Returns:
      DB name of its schema.
    • getADQLCatalogName

      public String getADQLCatalogName()
      Description copied from interface: DBTable
      Gets the ADQL name of the catalog which contains this table.

      Warning! Same rules as DBTable.getADQLName().

      Specified by:
      getADQLCatalogName in interface DBTable
      Returns:
      ADQL name of its catalog.
    • getDBCatalogName

      public String getDBCatalogName()
      Description copied from interface: DBTable
      Gets the DB name of the catalog which contains this table.

      Warning! Same rules as DBTable.getDBName().

      Specified by:
      getDBCatalogName in interface DBTable
      Returns:
      DB name of its catalog.
    • getColumn

      public DBColumn getColumn(String colName, boolean byAdqlName)
      Description copied from interface: DBTable
      Gets the definition of the specified column if it exists in this table.
      Specified by:
      getColumn in interface DBTable
      Parameters:
      colName - Name of the column (may be the ADQL or DB name depending of the second parameter).
      byAdqlName - true means the given name is the ADQL name of the column and that the research must be done on the ADQL name of columns, false means the same thing but with the DB name.
      Returns:
      The corresponding column, or NULL if the specified column had not been found.
    • copy

      public DBTable copy(String dbName, String adqlName)
      Description copied from interface: DBTable
      Makes a copy of this instance of DBTable, with the possibility to change the DB and ADQL names.

      IMPORTANT:

      • The given DB and ADQL name may be NULL. If NULL, the copy will contain exactly the same full name (DB and/or ADQL).
      • they may be qualified (that's to say: prefixed by the schema name or by the catalog and schema name). It means that it is possible to change the catalog, schema and table name in the copy.
      • they may be delimited (that's to say: written between double quotes to force case sensitivity).

      For instance:

      • .copy(null, "foo") => a copy with the same full DB name, but with no ADQL catalog and schema name and with an ADQL table name equals to "foo"
      • .copy("schema.table", null) => a copy with the same full ADQL name, but with no DB catalog name, with a DB schema name equals to "schema" and with a DB table name equals to "table"
      Specified by:
      copy in interface DBTable
      Parameters:
      dbName - Its new DB name. It may be qualified and/or delimited. It may also be NULL ; if so, the full DB name won't be different in the copy.
      adqlName - Its new ADQL name. It may be qualified and/or delimited. It may also be NULL ; if so, the full DB name won't be different in the copy.
      Returns:
      A modified copy of this DBTable.