public class TAPSchema extends java.lang.Object implements java.lang.Iterable<TAPTable>
Represent a schema as described by the IVOA standard in the TAP protocol definition.
This object representation has exactly the same fields as the column of the table TAP_SCHEMA.schemas.
But it also provides a way to add other data. For instance, if information not listed in the standard
may be stored here, they can be using the function setOtherData(Object)
. This object can be
a single value (integer, string, ...), but also a Map
, List
, etc...
Note:
On the contrary to TAPColumn
and TAPTable
, a TAPSchema
object MAY have no DB name.
But by default, at the creation the DB name is the simplified ADQL name (i.e. as it is returned by getADQLName()
).
Once created, it is possible to set the DB name with setDBName(String)
. This DB name MAY be qualified,
BUT MUST BE without double quotes.
Modifier and Type | Field and Description |
---|---|
protected java.lang.Object |
otherData
Let add some information in addition of the ones of the TAP protocol.
|
protected java.util.Map<java.lang.String,TAPTable> |
tables
List all tables contained inside this schema.
|
Constructor and Description |
---|
TAPSchema(java.lang.String schemaName)
Build a
TAPSchema instance with the given ADQL name. |
TAPSchema(java.lang.String schemaName,
java.lang.String description)
Build a
TAPSchema instance with the given ADQL name and description. |
TAPSchema(java.lang.String schemaName,
java.lang.String description,
java.lang.String utype)
Build a
TAPSchema instance with the given ADQL name, description and UType. |
Modifier and Type | Method and Description |
---|---|
TAPTable |
addTable(java.lang.String tableName)
Build a
TAPTable object whose the ADQL and DB name will the given one. |
TAPTable |
addTable(java.lang.String tableName,
TAPTable.TableType tableType,
java.lang.String description,
java.lang.String utype)
Build a
TAPTable object whose the ADQL and DB name will the given one. |
void |
addTable(TAPTable newTable)
Add the given table inside this schema.
|
java.lang.String |
getADQLName()
Get the name of this schema.
|
java.lang.String |
getDBName()
Get the name this schema MUST have in the database.
|
java.lang.String |
getDescription()
Get the description of this schema.
|
int |
getIndex()
Get the ordering index of this schema inside its whole schema set.
|
java.lang.String |
getName()
Deprecated.
Does not do anything special: just call
getADQLName() . |
int |
getNbTables()
Get the number of all tables contained inside this schema.
|
java.lang.Object |
getOtherData()
Get the other (piece of) information associated with this schema.
|
java.lang.String |
getRawName()
Get the full ADQL name of this schema, as it has been provided at initialization.
|
TAPTable |
getTable(java.lang.String tableName)
Search for a table having the given ADQL name.
|
java.lang.String |
getTitle()
Get the title of this schema.
|
java.lang.String |
getUtype()
Get the UType associating this schema with a data-model.
|
boolean |
hasTable(java.lang.String tableName)
Tell whether this schema contains a table having the given ADQL name.
|
boolean |
isEmpty()
Tell whether this schema contains no table.
|
java.util.Iterator<TAPTable> |
iterator() |
void |
removeAllTables()
Remove all the tables contained inside this schema.
|
TAPTable |
removeTable(java.lang.String tableName)
Remove the table having the given ADQL name.
|
void |
setDBName(java.lang.String name)
Set the name this schema MUST have in the database.
|
void |
setDescription(java.lang.String description)
Set the description of this schema.
|
void |
setIndex(int schemaIndex)
Set the ordering index of this schema inside its whole schema set.
|
void |
setOtherData(java.lang.Object data)
Set the other (piece of) information associated with this schema.
|
void |
setTitle(java.lang.String title)
Set the title of this schema.
|
void |
setUtype(java.lang.String utype)
Set the UType associating this schema with a data-model.
|
java.lang.String |
toString() |
protected java.lang.Object otherData
Integer
, a String
, a Map
, a List
, ...
Its content is totally free and never used or checked.protected final java.util.Map<java.lang.String,TAPTable> tables
public TAPSchema(java.lang.String schemaName) throws java.lang.NullPointerException
Build a TAPSchema
instance with the given ADQL name.
Note:
The DB name is set by default to the ADQL name (as returned by getADQLName()
).
To set the DB name, you MUST call then setDBName(String)
.
Important notes on the given ADQL name:
myCatalog.mySchema
will be considered
as the schema name instead of mySchema
.
getADQLName()
but will
still appear in the result of getRawName()
.
schemaName
- Name that this schema MUST have in ADQL queries.
CAN'T be NULL ; this name can never be changed after initialization.java.lang.NullPointerException
- If the given name is null
,
or if the given string is empty after simplification
(i.e. without the surrounding double quotes).public TAPSchema(java.lang.String schemaName, java.lang.String description) throws java.lang.NullPointerException
Build a TAPSchema
instance with the given ADQL name and description.
Note:
The DB name is set by default to the ADQL name (as returned by getADQLName()
).
To set the DB name, you MUST call then setDBName(String)
.
Important notes on the given ADQL name:
myCatalog.mySchema
will be considered
as the schema name instead of mySchema
.
getADQLName()
but will
still appear in the result of getRawName()
.
schemaName
- Name that this schema MUST have in ADQL queries.
CAN'T be NULL ; this name can never be changed after initialization.description
- Description of this schema. MAY be NULLjava.lang.NullPointerException
- If the given name is null
,
or if the given string is empty after simplification
(i.e. without the surrounding double quotes).public TAPSchema(java.lang.String schemaName, java.lang.String description, java.lang.String utype) throws java.lang.NullPointerException
Build a TAPSchema
instance with the given ADQL name, description and UType.
Note:
The DB name is set by default to the ADQL name (as returned by getADQLName()
).
To set the DB name, you MUST call then setDBName(String)
.
Important notes on the given ADQL name:
myCatalog.mySchema
will be considered
as the schema name instead of mySchema
.
getADQLName()
but will
still appear in the result of getRawName()
.
schemaName
- Name that this schema MUST have in ADQL queries.
CAN'T be NULL ; this name can never be changed after initialization.description
- Description of this schema. MAY be NULLutype
- UType associating this schema with a data-model. MAY be NULLjava.lang.NullPointerException
- If the given name is null
,
or if the given string is empty after simplification
(i.e. without the surrounding double quotes).@Deprecated public final java.lang.String getName()
getADQLName()
.getADQLName()
public final java.lang.String getADQLName()
Note: If a simplification is needed, the double quotes surrounding the ADQL name, will be removed.
public final java.lang.String getRawName()
public final java.lang.String getDBName()
public final void setDBName(java.lang.String name)
Notes:
getDBName()
will then return NULL.name
- Its new DB name. MAY be NULLpublic final java.lang.String getTitle()
public final void setTitle(java.lang.String title)
title
- Its new title. MAY be NULLpublic final java.lang.String getDescription()
public final void setDescription(java.lang.String description)
description
- Its new description. MAY be NULLpublic final java.lang.String getUtype()
public final void setUtype(java.lang.String utype)
utype
- Its new UType. MAY be NULLpublic final int getIndex()
public final void setIndex(int schemaIndex)
schemaIndex
- Its new ordering index.public java.lang.Object getOtherData()
Get the other (piece of) information associated with this schema.
Note:
By default, NULL is returned, but it may be any kind of value (Integer
,
String
, Map
, List
, ...).
public void setOtherData(java.lang.Object data)
data
- Another information about this schema. MAY be NULLpublic final void addTable(TAPTable newTable)
Add the given table inside this schema.
Note: If the given table is NULL, nothing will be done.
Important note:
By adding the given table inside this schema, it
will be linked with this schema using TAPTable.setSchema(TAPSchema)
.
In this function, if the table was already linked with another TAPSchema
,
the former link is removed using removeTable(String)
.
newTable
- Table to add inside this schema.public TAPTable addTable(java.lang.String tableName)
Build a TAPTable
object whose the ADQL and DB name will the given one.
Then, add this table inside this schema.
Note:
The built TAPTable
object is returned, so that being modified afterwards if needed.
tableName
- ADQL name (and indirectly also the DB name) of the table to create and add.TAPTable
object,
or NULL if the given name is NULL or an empty string.TAPTable.TAPTable(String)
,
addTable(TAPTable)
public TAPTable addTable(java.lang.String tableName, TAPTable.TableType tableType, java.lang.String description, java.lang.String utype)
Build a TAPTable
object whose the ADQL and DB name will the given one.
Then, add this table inside this schema.
Note:
The built TAPTable
object is returned, so that being modified afterwards if needed.
tableName
- ADQL name (and indirectly also the DB name) of the table to create and add.tableType
- Type of the new table. If NULL, "table" will be the type of the created table.description
- Description of the new table. MAY be NULLutype
- UType associating the new column with a data-model. MAY be NULLTAPTable
object,
or NULL if the given name is NULL or an empty string.TAPTable.TAPTable(String, TableType, String, String)
,
addTable(TAPTable)
public final boolean hasTable(java.lang.String tableName)
Tell whether this schema contains a table having the given ADQL name.
Important note: This function is case sensitive!
tableName
- Name of the table whose the existence in this schema must be checked.public final TAPTable getTable(java.lang.String tableName)
Search for a table having the given ADQL name.
Important note: This function is case sensitive!
tableName
- ADQL name of the table to search.public final int getNbTables()
public final boolean isEmpty()
public final TAPTable removeTable(java.lang.String tableName)
Remove the table having the given ADQL name.
Important note: This function is case sensitive!
Note: If the specified table is removed, its schema link is also deleted.
WARNING:
If the goal of this function's call is to delete definitely the specified table
from the metadata, you SHOULD also call TAPTable.removeAllForeignKeys()
.
Indeed, foreign keys of the table would still link the removed table with other tables
AND columns of the whole metadata set.
tableName
- ADQL name of the table to remove from this schema.public final void removeAllTables()
Remove all the tables contained inside this schema.
Note: When a table is removed, its schema link is also deleted.
CAUTION:
If the goal of this function's call is to delete definitely all the tables of this schema
from the metadata, you SHOULD also call TAPTable.removeAllForeignKeys()
on all tables before calling this function.
Indeed, foreign keys of the tables would still link the removed tables with other tables
AND columns of the whole metadata set.
public java.util.Iterator<TAPTable> iterator()
iterator
in interface java.lang.Iterable<TAPTable>
public java.lang.String toString()
toString
in class java.lang.Object