public class TLcdDatabaseModelDescriptor extends TLcdFeaturedModelDescriptor implements ILcdDatabaseModelDescriptor, com.luciad.internal.format.database.ILinDatabaseModelDescriptor2, ILcdAnnotatedElement
ILcdDatabaseModelDescriptor
describes a spatial database.
For accessing an existing spatial table, the following information is required:
Optionally, the descriptor can have additional properties set:
For creating a new spatial table, the following additional information is required:
Modifier and Type | Field and Description |
---|---|
protected Connection |
fConnection |
static String |
TYPE_NAME |
fFeatureClasses, fFeatureNames
Constructor and Description |
---|
TLcdDatabaseModelDescriptor()
Constructs a new (invalid) database table descriptor with default
properties.
|
TLcdDatabaseModelDescriptor(String aDriver,
String aURL,
Properties aConnectionProperties,
String aTableName,
String aGeometryColumnName)
Constructs a new database table descriptor, based on a JDBC driver and URL.
|
TLcdDatabaseModelDescriptor(String aDriver,
String aURL,
Properties aConnectionProperties,
String aTableName,
String aGeometryColumnName,
String[] aFeatureNames,
int aPrimaryFeatureIndex)
Constructs a new database table descriptor, based on a JDBC driver and URL.
|
TLcdDatabaseModelDescriptor(String aDriver,
String aURL,
Properties aConnectionProperties,
String aTableName,
String aGeometryColumnName,
String[] aFeatureNames,
int aPrimaryFeatureIndex,
boolean aPrimaryFeatureAutoGenerated)
Constructs a new database table descriptor, based on a JDBC driver and URL.
|
Modifier and Type | Method and Description |
---|---|
<T extends ILcdAnnotation> |
addAnnotation(ILcdAnnotation aAnnotation)
Adds the given annotation to this element.
|
Object |
clone() |
void |
close()
Closes the
Connection of this descriptor, if it was opened. |
<T extends ILcdAnnotation> |
getAnnotation(Class<T> aAnnotationClass)
Returns the element's annotation for the specified class if such an annotation is present,
else null.
|
Collection<ILcdAnnotation> |
getAnnotations()
Returns all annotations present on this element as an unmodifiable collection.
|
ILcdBounds |
getBounds()
returns the bounds of the geometry.
|
String |
getColumnNames()
Concatenates the main column name and the feature column names into
a single
String of comma-separated column names. |
String |
getColumnNames(boolean aIncludeGeometryColumn,
boolean aIncludePrimaryFeatureColumn)
Concatenates the main column name (optionally) and the feature column names
(optionally excluding the primary feature column) into a single
String of comma-separated column names. |
String |
getColumnNamesAndTypes()
Concatenates the main column name and type, and the feature column names
and types into a single
String of comma-separated column names
and types. |
String |
getColumnNamesAndTypes(boolean aIncludeGeometryColumn,
boolean aIncludePrimaryFeatureColumn,
boolean aMarkPrimaryFeatureColumn)
Concatenates the main column name and type (optionally), and the feature
column names and types (optionally excluding the primary feature column)
into a single
String of comma-separated column names and types. |
Connection |
getConnection()
Returns the database connection.
|
Properties |
getConnectionProperties()
Returns the connection properties.
|
TLcdDataModel |
getDataModel()
Returns the data model that describes the elements of the model.
|
String |
getDriver()
Returns the JDBC driver name.
|
ILcdEllipsoid |
getEllipsoid()
Returns the ellipsoid of the database object reference.
|
String |
getFeatureDisplayName(int aIndex)
Returns the display name name of a specified feature.
|
String |
getFeatureType(int aIndex)
Returns the type of a given feature.
|
String |
getGeometryColumnName()
Returns the name of the table column containing the geometry.
|
String |
getGeometryQueryColumnName()
Returns the optional table column containing the geometry on which the
spatial queries are be performed.
|
String |
getGeometryType()
Returns the type of the geometry.
|
TLcdDataType |
getModelElementType()
Returns the type of all the model elements.
|
Set<TLcdDataType> |
getModelElementTypes()
Returns a set containing all the data types of which instances can be elements in the model
associated with this descriptor.
|
Set<TLcdDataType> |
getModelTypes()
Returns a set containing all the types of which instances can be used (including both
top-level elements and child objects) in the model associated with this descriptor.
|
int |
getPrimaryFeatureIndex()
Returns the primary feature index.
|
String |
getSelectionFilter()
Returns the string representing the selection filter.
|
String |
getSelectionTables()
Returns the names of the additional tables used in the select query
|
int |
getSRID()
Returns the Spatial Reference ID number.
|
String |
getTableName()
Returns the name of the database table.
|
String |
getURL()
Returns the JDBC connection URL.
|
boolean |
isAlwaysCloseConnection()
Returns whether a connection is always closed after a query has been
performed.
|
boolean |
isAnnotationPresent(Class<? extends ILcdAnnotation> aAnnotationClass)
Returns true if an annotation for the specified class is present on this element,
else false.
|
boolean |
isPrimaryFeatureAutoGenerated()
Returns whether the primary key is automatically generated by the database.
|
<T extends ILcdAnnotation> |
removeAnnotation(Class<T> aAnnotationClass)
Removes the annotation of the given class from this element.
|
void |
setAlwaysCloseConnection(boolean aAlwaysCloseConnection)
Specifies to always close the connection after a query has been performed.
|
void |
setBounds(ILcdBounds aBounds)
Sets the bounds of the geometry.
|
void |
setConnectionProperties(Properties aConnectionProperties)
Sets the connection properties.
|
void |
setDriver(String aDriver)
Sets the JDBC driver name.
|
void |
setEllipsoid(ILcdEllipsoid aEllipsoid)
Sets the ellipsoid of the database object's reference.
|
void |
setFeatureClasses(Class[] aFeatureClasses)
Sets the classes of the features that are decoded.
|
void |
setFeatureDisplayNames(String[] aFeatureDisplayNames)
Sets the display names of the features that are decoded.
|
void |
setFeatureNames(String[] aFeatureNames)
Sets the names of the features to be selected.
|
void |
setFeatureTypes(String[] aFeatureTypes)
Sets the types of the features.
|
void |
setGeometryColumnName(String aName)
Sets the name of the column containing the database geometry object.
|
void |
setGeometryQueryColumnName(String aName)
Sets an optional table column containing the geometry on which the spatial
queries will be performed.
|
void |
setGeometryType(String aGeometryType)
Sets the type of the geometry.
|
void |
setPrimaryFeatureAutoGenerated(boolean aPrimaryFeatureAutoGenerated)
Sets whether the primary key is automatically generated by the database.
|
void |
setPrimaryFeatureIndex(int aPrimaryFeatureIndex)
Sets the primary feature index
|
void |
setSelectionFilter(String aSelectionFilter)
A selection filter string , normally appended to the WHERE part of the
select query.
|
void |
setSelectionTables(String aSelectionTables)
Sets the names of additional tables used in the select query.
|
void |
setSRID(int aSRID)
Sets the Spatial Reference ID number.
|
void |
setTableName(String aName)
Sets the name of the database table.
|
void |
setTypeName(String aTypeName)
Sets the type name.
|
void |
setURL(String aURL)
Sets the JDBC connection URL.
|
getFeatureClass, getFeatureCount, getFeaturedDescriptor, getFeatureIndex, getFeatureName
getDisplayName, getSourceName, getTypeName, setDisplayName, setSourceName, sourceNameToDisplayName
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
closeConnection
getFeatureName
getDisplayName, getSourceName, getTypeName
getFeatureClass, getFeatureCount, getFeatureIndex, getFeatureUnitOfMeasure
public static final String TYPE_NAME
protected transient Connection fConnection
public TLcdDatabaseModelDescriptor()
public TLcdDatabaseModelDescriptor(String aDriver, String aURL, Properties aConnectionProperties, String aTableName, String aGeometryColumnName)
aDriver
- the JDBC driver name.aURL
- the JDBC connection URL.aConnectionProperties
- the connection properties, including 'user'
and 'password'.aTableName
- the database table name.aGeometryColumnName
- the name of the column containing spatial objects.public TLcdDatabaseModelDescriptor(String aDriver, String aURL, Properties aConnectionProperties, String aTableName, String aGeometryColumnName, String[] aFeatureNames, int aPrimaryFeatureIndex)
aDriver
- the JDBC driver name.aURL
- the JDBC connection URL.aConnectionProperties
- the connection properties, including 'user'
and 'password'.aTableName
- the database table name.aGeometryColumnName
- the name of the column containing spatial objects.aFeatureNames
- the column names of the features that should be
retrieved.aPrimaryFeatureIndex
- the index of the feature that can be used a a
primary key on the spatial table.public TLcdDatabaseModelDescriptor(String aDriver, String aURL, Properties aConnectionProperties, String aTableName, String aGeometryColumnName, String[] aFeatureNames, int aPrimaryFeatureIndex, boolean aPrimaryFeatureAutoGenerated)
aDriver
- the JDBC driver name.aURL
- the JDBC connection URL.aConnectionProperties
- the connection properties, including 'user'
and 'password'.aTableName
- the database table name.aGeometryColumnName
- the name of the column containing spatial objects.aFeatureNames
- the column names of the features that should be
retrieved.aPrimaryFeatureIndex
- the index of the feature that can be used a a
primary key on the spatial table.aPrimaryFeatureAutoGenerated
- specifies whether the primary key is
automatically generated by the database.public void setDriver(String aDriver)
public String getDriver()
public void setURL(String aURL)
public String getURL()
public void setTypeName(String aTypeName)
setTypeName
in class TLcdModelDescriptor
aTypeName
- The new type namepublic void setConnectionProperties(Properties aConnectionProperties)
public Properties getConnectionProperties()
public void setTableName(String aName)
ILcdDatabaseModelDescriptor
setTableName
in interface ILcdDatabaseModelDescriptor
aName
- the name of the database table.public String getTableName()
ILcdDatabaseModelDescriptor
getTableName
in interface ILcdDatabaseModelDescriptor
public void setGeometryColumnName(String aName)
ILcdDatabaseModelDescriptor
setGeometryColumnName
in interface ILcdDatabaseModelDescriptor
aName
- the name of the table column containing the geometry.public String getGeometryColumnName()
ILcdDatabaseModelDescriptor
getGeometryColumnName
in interface ILcdDatabaseModelDescriptor
public void setGeometryQueryColumnName(String aName)
null
, meaning
that it is the same a the table column containing the geometry that is
decoded.public String getGeometryQueryColumnName()
public void setFeatureNames(String[] aFeatureNames)
ILcdDatabaseModelDescriptor
setFeatureNames
in interface ILcdDatabaseModelDescriptor
aFeatureNames
- a list of feature names.public void setFeatureDisplayNames(String[] aFeatureDisplayNames)
public String getFeatureDisplayName(int aIndex)
public void setFeatureClasses(Class[] aFeatureClasses)
public void setPrimaryFeatureIndex(int aPrimaryFeatureIndex)
ILcdDatabaseModelDescriptor
setPrimaryFeatureIndex
in interface ILcdDatabaseModelDescriptor
aPrimaryFeatureIndex
- the primary feature indexpublic int getPrimaryFeatureIndex()
ILcdDatabaseModelDescriptor
getPrimaryFeatureIndex
in interface ILcdDatabaseModelDescriptor
public void setPrimaryFeatureAutoGenerated(boolean aPrimaryFeatureAutoGenerated)
public boolean isPrimaryFeatureAutoGenerated()
public void setSelectionTables(String aSelectionTables)
ILcdDatabaseModelDescriptor
setSelectionTables
in interface ILcdDatabaseModelDescriptor
aSelectionTables
- a list of additional tables separated by columns.public String getSelectionTables()
ILcdDatabaseModelDescriptor
getSelectionTables
in interface ILcdDatabaseModelDescriptor
public void setSelectionFilter(String aSelectionFilter)
ILcdDatabaseModelDescriptor
setSelectionFilter
in interface ILcdDatabaseModelDescriptor
aSelectionFilter
- a selection filter string.public String getSelectionFilter()
ILcdDatabaseModelDescriptor
getSelectionFilter
in interface ILcdDatabaseModelDescriptor
public void setAlwaysCloseConnection(boolean aAlwaysCloseConnection)
public boolean isAlwaysCloseConnection()
isAlwaysCloseConnection
in interface com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
public void setSRID(int aSRID)
ILcdDatabaseModelDescriptor
setSRID
in interface ILcdDatabaseModelDescriptor
aSRID
- a spatial reference ID.public int getSRID()
ILcdDatabaseModelDescriptor
getSRID
in interface ILcdDatabaseModelDescriptor
public void setEllipsoid(ILcdEllipsoid aEllipsoid)
ILcdDatabaseModelDescriptor
setEllipsoid
in interface ILcdDatabaseModelDescriptor
aEllipsoid
- the ellipsoid of the database object's reference.public ILcdEllipsoid getEllipsoid()
ILcdDatabaseModelDescriptor
getEllipsoid
in interface ILcdDatabaseModelDescriptor
public void setBounds(ILcdBounds aBounds)
ILcdDatabaseModelDescriptor
setBounds
in interface ILcdDatabaseModelDescriptor
aBounds
- the bounds of the geometry.public ILcdBounds getBounds()
ILcdDatabaseModelDescriptor
getBounds
in interface ILcdDatabaseModelDescriptor
public void setGeometryType(String aGeometryType)
ILcdDatabaseModelDescriptor
setGeometryType
in interface ILcdDatabaseModelDescriptor
aGeometryType
- type of the geometry.public String getGeometryType()
ILcdDatabaseModelDescriptor
getGeometryType
in interface ILcdDatabaseModelDescriptor
public void setFeatureTypes(String[] aFeatureTypes)
ILcdDatabaseModelDescriptor
setFeatureTypes
in interface ILcdDatabaseModelDescriptor
aFeatureTypes
- the types of the features.public String getFeatureType(int aIndex)
ILcdDatabaseModelDescriptor
getFeatureType
in interface ILcdDatabaseModelDescriptor
aIndex
- the feature index.public String getColumnNames()
ILcdDatabaseModelDescriptor
String
of comma-separated column names.getColumnNames
in interface ILcdDatabaseModelDescriptor
getColumnNames
in interface com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
public String getColumnNames(boolean aIncludeGeometryColumn, boolean aIncludePrimaryFeatureColumn)
String
of comma-separated column names.getColumnNames
in interface com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
aIncludeGeometryColumn
- specifies whether the geometry column name
should be included.aIncludePrimaryFeatureColumn
- specifies whether the primary feature
column name should be included.public String getColumnNamesAndTypes() throws IllegalArgumentException
ILcdDatabaseModelDescriptor
String
of comma-separated column names
and types.getColumnNamesAndTypes
in interface ILcdDatabaseModelDescriptor
IllegalArgumentException
public String getColumnNamesAndTypes(boolean aIncludeGeometryColumn, boolean aIncludePrimaryFeatureColumn, boolean aMarkPrimaryFeatureColumn) throws IllegalArgumentException
String
of comma-separated column names and types.aIncludeGeometryColumn
- specifies whether the geometry column name
and type should be included.aIncludePrimaryFeatureColumn
- specifies whether the primary feature
column name and type should be included.aMarkPrimaryFeatureColumn
- specifies whether the primary feature
column name should be marked with
the string "PRIMARY KEY".IllegalArgumentException
public Connection getConnection() throws SQLException
com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
getConnection
in interface com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
SQLException
public void close()
ILcdDatabaseModelDescriptor
Connection
of this descriptor, if it was opened.close
in interface ILcdDatabaseModelDescriptor
public Object clone()
clone
in interface ILcdDatabaseModelDescriptor
clone
in class Object
public TLcdDataModel getDataModel()
ILcdDataModelDescriptor
Returns the data model that describes the elements of the model. Note that not necessarily all data in the model will be of a type of this data model. Very likely, types from the dependencies of the returned data model are used as well.
In case the model accepts objects from multiple data models, an anonymous
data model that depends on all these data models should be returned
(see TLcdDataModelBuilder.createAnonymousDataModel(java.util.Collection)
).
getDataModel
in interface ILcdDataModelDescriptor
public Set<TLcdDataType> getModelElementTypes()
ILcdDataModelDescriptor
Returns a set containing all the data types of which instances can be elements in the model associated with this descriptor. Implementations are free to limit the result to only include the types of which there are actually elements in the model; but they are not required to do so.
Implementations should return null
in case they don't know
which element types are present in the model.
For each element of the model associated with this model descriptor, the following holds true :
getModelElementTypes().contains( element.getDataType() )
.
getModelElementTypes
in interface ILcdDataModelDescriptor
public Set<TLcdDataType> getModelTypes()
ILcdDataModelDescriptor
Returns a set containing all the types of which instances can be used (including both top-level elements and child objects) in the model associated with this descriptor. Implementations are free to limit the result to only include the types of which there are actually instances in the model; but they are not required to do so.
A simple and correct implementation would be to return
getDataModel().getTypes()
. Implementations are encouraged to return a subset of
this set if they can do so without spending an unreasonable amount of resources.
Implementations should return null
in case they don't know
which types are present in the model.
getModelTypes
in interface ILcdDataModelDescriptor
public TLcdDataType getModelElementType()
getModelElementType()
returns a set that contains this type as single element.getModelElementType
in interface com.luciad.internal.format.database.ILinDatabaseModelDescriptor2
ILcdDataModelDescriptor.getModelElementTypes()
public <T extends ILcdAnnotation> T addAnnotation(ILcdAnnotation aAnnotation)
ILcdAnnotatedElement
addAnnotation
in interface ILcdAnnotatedElement
aAnnotation
- the annotation to addpublic <T extends ILcdAnnotation> T removeAnnotation(Class<T> aAnnotationClass)
ILcdAnnotatedElement
Removes the annotation of the given class from this element.
Note that the exact annotation class needs to be passed as parameter.
In other words, in case the element
is only annotated with instances of subclasses of the given annotation class,
nothing is removed and null
is returned.
removeAnnotation
in interface ILcdAnnotatedElement
aAnnotationClass
- the class of annotation to removepublic <T extends ILcdAnnotation> T getAnnotation(Class<T> aAnnotationClass)
ILcdAnnotatedElement
Returns the element's annotation for the specified class if such an annotation is present, else null.
Note that the exact annotation class needs to be passed as parameter.
In other words, in case the element
is only annotated with instances of subclasses of the given annotation class,
null
is returned.
getAnnotation
in interface ILcdAnnotatedElement
aAnnotationClass
- - the Class object corresponding to the annotation typepublic Collection<ILcdAnnotation> getAnnotations()
ILcdAnnotatedElement
getAnnotations
in interface ILcdAnnotatedElement
public boolean isAnnotationPresent(Class<? extends ILcdAnnotation> aAnnotationClass)
ILcdAnnotatedElement
Returns true if an annotation for the specified class is present on this element, else false. This method is designed primarily for convenient access to marker annotations.
Note that the exact annotation class needs to be passed as parameter.
In other words, in case the element
is only annotated with instances of subclasses of the given annotation class,
false
is returned.
isAnnotationPresent
in interface ILcdAnnotatedElement
aAnnotationClass
- the Class object corresponding to the annotation class