org.geotools.metadata.sql
Class MetadataSource

java.lang.Object
  extended byorg.geotools.metadata.sql.MetadataSource

public class MetadataSource
extends java.lang.Object

A connection to a metadata database. The metadata database can be created using one of the scripts suggested in GeoAPI, for example create.sql. Then, in order to get for example a telephone number, the following code may be used.

 import org.opengis.metadata.citation.Telephone;
 ...
 Connection     connection = ...
 MetadataSource source     = new MetadataSource(connection);
 Telephone      telephone  = (Telephone) source.getEntry(Telephone.class, id);
 
where is the primary key value for the desired record in the table.

Since:
2.1
Author:
Toura?vane, Olivier Kartotaroeno, Martin Desruisseaux

Constructor Summary
MetadataSource(java.sql.Connection connection)
          Creates a new metadata source.
 
Method Summary
 void close()
          Close all connections used in this object.
 java.lang.Object getEntry(java.lang.Class type, java.lang.String identifier)
          Returns an implementation of the specified metadata interface filled with the data referenced by the specified identifier.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MetadataSource

public MetadataSource(java.sql.Connection connection)
Creates a new metadata source.

Parameters:
connection - The connection to the database.
Method Detail

getEntry

public java.lang.Object getEntry(java.lang.Class type,
                                 java.lang.String identifier)
                          throws java.sql.SQLException
Returns an implementation of the specified metadata interface filled with the data referenced by the specified identifier. Alternatively, this method can also returns a CodeList element.

Parameters:
type - The interface to implement (e.g. Citation), or the CodeList.
identifier - The identifier used in order to locate the record for the metadata entity to be created. This is usually the primary key of the record to search for.
Returns:
An implementation of the required interface, or the code list element.
Throws:
java.sql.SQLException - if a SQL query failed.

close

public void close()
           throws java.sql.SQLException
Close all connections used in this object.

Throws:
java.sql.SQLException


Copyright © GeoTools. All Rights Reserved.