Class DefaultDBTable
- java.lang.Object
-
- adql.db.DefaultDBTable
-
- Direct Known Subclasses:
DBTableAlias
public class DefaultDBTable extends java.lang.Object implements DBTable
Default implementation ofDBTable.- Version:
- 1.4 (08/2015)
- Author:
- Grégory Mantelet (CDS;ARI)
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringadqlCatalogNameprotected java.lang.StringadqlNameprotected java.lang.StringadqlSchemaNameprotected java.util.Map<java.lang.String,DBColumn>columnsprotected java.lang.StringdbCatalogNameprotected java.lang.StringdbNameprotected java.lang.StringdbSchemaName
-
Constructor Summary
Constructors Constructor Description DefaultDBTable(java.lang.String dbName)Builds a defaultDBTablewith the given DB name.DefaultDBTable(java.lang.String dbName, java.lang.String adqlName)Builds a defaultDBTablewith the given DB and ADQL names.DefaultDBTable(java.lang.String dbCatName, java.lang.String dbSchemName, java.lang.String dbName)Builds defaultDBTablewith a DB catalog, schema and table names.DefaultDBTable(java.lang.String dbCatName, java.lang.String adqlCatName, java.lang.String dbSchemName, java.lang.String adqlSchemName, java.lang.String dbName, java.lang.String adqlName)Builds defaultDBTablewith the DB and ADQL names for the catalog, schema and table.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddAllColumns(java.util.Collection<DBColumn> colList)voidaddColumn(DBColumn column)DBTablecopy(java.lang.String dbName, java.lang.String adqlName)Makes a copy of this instance ofDBTable, with the possibility to change the DB and ADQL names.java.lang.StringgetADQLCatalogName()Gets the ADQL name of the catalog which contains this table.java.lang.StringgetADQLName()Gets the name of this table (without any prefix and double-quotes).java.lang.StringgetADQLSchemaName()Gets the ADQL name of the schema which contains this table.DBColumngetColumn(java.lang.String colName, boolean byAdqlName)Case sensitive !java.lang.StringgetDBCatalogName()Gets the DB name of the catalog which contains this table.java.lang.StringgetDBName()Gets the name of this table in the "database".java.lang.StringgetDBSchemaName()Gets the DB name of the schema which contains this table.booleanhasColumn(java.lang.String colName, boolean byAdqlName)java.util.Iterator<DBColumn>iterator()static java.lang.StringjoinTableName(java.lang.String[] nameParts)Join the last 3 items of the given string array with a dot ('.').voidsetADQLCatalogName(java.lang.String name)voidsetADQLName(java.lang.String name)voidsetADQLSchemaName(java.lang.String name)static java.lang.String[]splitTableName(java.lang.String table)Splits the given table name in 3 parts: catalog, schema, table.
-
-
-
Field Detail
-
dbCatalogName
protected java.lang.String dbCatalogName
-
dbSchemaName
protected java.lang.String dbSchemaName
-
dbName
protected java.lang.String dbName
-
adqlCatalogName
protected java.lang.String adqlCatalogName
-
adqlSchemaName
protected java.lang.String adqlSchemaName
-
adqlName
protected java.lang.String adqlName
-
columns
protected java.util.Map<java.lang.String,DBColumn> columns
-
-
Constructor Detail
-
DefaultDBTable
public DefaultDBTable(java.lang.String dbName)
Builds a default
DBTablewith the given DB name.With this constructor: ADQL name = DB name.
Note: The table name can be prefixed by a schema and a catalog: t1 or schema1.t1 or cat1.schema1.t2
- Parameters:
dbName- Database name (it will be also used as ADQL table name).- See Also:
DefaultDBTable(String, String)
-
DefaultDBTable
public DefaultDBTable(java.lang.String dbName, java.lang.String adqlName)Builds a default
DBTablewith the given DB and ADQL names.Note: The table names can be prefixed by a schema and a catalog: t1 or schema1.t1 or cat1.schema1.t2
- Parameters:
dbName- Database name.adqlName- Name used in ADQL queries.
-
DefaultDBTable
public DefaultDBTable(java.lang.String dbCatName, java.lang.String dbSchemName, java.lang.String dbName)Builds defaultDBTablewith a DB catalog, schema and table names.- Parameters:
dbCatName- Database catalog name (it will be also used as ADQL catalog name).dbSchemName- Database schema name (it will be also used as ADQL schema name).dbName- Database table name (it will be also used as ADQL table name).- See Also:
DefaultDBTable(String, String, String, String, String, String)
-
DefaultDBTable
public DefaultDBTable(java.lang.String dbCatName, java.lang.String adqlCatName, java.lang.String dbSchemName, java.lang.String adqlSchemName, java.lang.String dbName, java.lang.String adqlName)Builds defaultDBTablewith the DB and ADQL names for the catalog, schema and table.- Parameters:
dbCatName- Database catalog name.adqlCatName- Catalog name used in ADQL queries. If NULL, it will be set to dbCatName.dbSchemName- Database schema name.adqlSchemName- Schema name used in ADQL queries. If NULL, it will be set to dbSchemName.dbName- Database table name.adqlName- Table name used in ADQL queries. If NULL, it will be set to dbName.
-
-
Method Detail
-
getDBName
public final java.lang.String getDBName()
Description copied from interface:DBTableGets the name of this table in the "database".
-
getDBSchemaName
public final java.lang.String getDBSchemaName()
Description copied from interface:DBTableGets the DB name of the schema which contains this table.- Specified by:
getDBSchemaNamein interfaceDBTable- Returns:
- DB name of its schema.
-
getDBCatalogName
public final java.lang.String getDBCatalogName()
Description copied from interface:DBTableGets the DB name of the catalog which contains this table.- Specified by:
getDBCatalogNamein interfaceDBTable- Returns:
- DB name of its catalog.
-
getADQLName
public final java.lang.String getADQLName()
Description copied from interface:DBTableGets the name of this table (without any prefix and double-quotes).- Specified by:
getADQLNamein interfaceDBTable- Returns:
- Its ADQL name.
-
setADQLName
public void setADQLName(java.lang.String name)
-
getADQLSchemaName
public final java.lang.String getADQLSchemaName()
Description copied from interface:DBTableGets the ADQL name of the schema which contains this table.- Specified by:
getADQLSchemaNamein interfaceDBTable- Returns:
- ADQL name of its schema.
-
setADQLSchemaName
public void setADQLSchemaName(java.lang.String name)
-
getADQLCatalogName
public final java.lang.String getADQLCatalogName()
Description copied from interface:DBTableGets the ADQL name of the catalog which contains this table.- Specified by:
getADQLCatalogNamein interfaceDBTable- Returns:
- ADQL name of its catalog.
-
setADQLCatalogName
public void setADQLCatalogName(java.lang.String name)
-
getColumn
public DBColumn getColumn(java.lang.String colName, boolean byAdqlName)
Case sensitive !
Research optimized for researches by ADQL name.
- Specified by:
getColumnin interfaceDBTable- 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.
- See Also:
DBTable.getColumn(java.lang.String, boolean)
-
hasColumn
public boolean hasColumn(java.lang.String colName, boolean byAdqlName)
-
iterator
public java.util.Iterator<DBColumn> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<DBColumn>
-
addColumn
public void addColumn(DBColumn column)
-
addAllColumns
public void addAllColumns(java.util.Collection<DBColumn> colList)
-
splitTableName
public static final java.lang.String[] splitTableName(java.lang.String table)
Splits the given table name in 3 parts: catalog, schema, table.- Parameters:
table- The table name to split.- Returns:
- A String array of 3 items: [0]=catalog, [1]=schema, [0]=table.
-
joinTableName
public static final java.lang.String joinTableName(java.lang.String[] nameParts)
Join the last 3 items of the given string array with a dot ('.'). These three parts should be: [0]=catalog name, [1]=schema name, [2]=table name.
If the array contains less than 3 items, all the given items will be though joined. However, if it contains more than 3 items, only the three last items will be.
A null item will be written as an empty string (string of length 0 ; "").
In the case the first and the third items are not null, but the second is null, the final string will contain in the middle two dots. Example: if the array is {"cat", NULL, "table"}, then the joined string will be: "cat..table".
- Parameters:
nameParts- String items to join.- Returns:
- A string joining the 3 last string items of the given array, or an empty string if the given array is NULL.
- Since:
- 1.3
-
copy
public DBTable copy(java.lang.String dbName, java.lang.String adqlName)
Description copied from interface:DBTableMakes 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).
And 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.
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", ) => 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:
copyin interfaceDBTable- Parameters:
dbName- Its new DB name. It may be qualified. 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. 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.
-
-