org.geotools.data.jdbc
Class JDBCFeatureSource

java.lang.Object
  extended byorg.geotools.data.jdbc.JDBCFeatureSource
All Implemented Interfaces:
FeatureSource
Direct Known Subclasses:
DB2FeatureSource, JDBCFeatureStore

public class JDBCFeatureSource
extends java.lang.Object
implements FeatureSource

A JDBCFeatureSource that can opperate as a starting point for your own implementations.

This class is distinct from the AbstractFeatureSource implementations as JDBC provides us with so many opertunities for optimization.

Client code must implement: It is recomended that clients implement optimizations for:

Author:
Jody Garnett, Refractions Research

Constructor Summary
JDBCFeatureSource(JDBC1DataStore jdbcDataStore, FeatureType featureType)
          JDBCFeatureSource creation.
 
Method Summary
 void addFeatureListener(FeatureListener listener)
          Adds FeatureListener to the JDBCDataStore against this FeatureSource.
protected  void close(java.sql.Connection conn, Transaction trans, java.sql.SQLException sqle)
           
protected  void close(java.sql.ResultSet rs)
           
protected  void close(java.sql.Statement statement)
           
 int count(Query query, Transaction transaction)
          Direct SQL query number of rows in query.
 com.vividsolutions.jts.geom.Envelope getBounds()
          Retrieve Bounds of all Features.
 com.vividsolutions.jts.geom.Envelope getBounds(Query query)
          Retrieve Bounds of Query results.
protected  java.sql.Connection getConnection()
           
 int getCount(Query query)
          Retrieve total number of Query results.
 DataStore getDataStore()
          Retrieve DataStore for this FetureSource.
 FeatureCollection getFeatures()
          Retrieve all Features
 FeatureCollection getFeatures(Filter filter)
          Retrieve all Feature matching the Filter
 FeatureCollection getFeatures(Query request)
          Provides an interface to for the Resutls of a Query.
 JDBC1DataStore getJDBCDataStore()
          Allows access to JDBCDataStore().
 FeatureType getSchema()
          Retrieve FeatureType represented by this FeatureSource
 Transaction getTransaction()
          Retrieve the Transaction this FeatureSource is opperating against.
 void removeFeatureListener(FeatureListener listener)
          Remove FeatureListener to the JDBCDataStore against this FeatureSource.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JDBCFeatureSource

public JDBCFeatureSource(JDBC1DataStore jdbcDataStore,
                         FeatureType featureType)
JDBCFeatureSource creation.

Constructs a FeatureStore that opperates against the provided jdbcDataStore to serve up the contents of featureType.

Parameters:
jdbcDataStore - DataStore containing contents
featureType - FeatureType being served
Method Detail

getDataStore

public DataStore getDataStore()
Retrieve DataStore for this FetureSource.

Specified by:
getDataStore in interface FeatureSource
Returns:
See Also:
FeatureSource.getDataStore()

getJDBCDataStore

public JDBC1DataStore getJDBCDataStore()
Allows access to JDBCDataStore(). Description

Subclass must implement

Returns:
JDBDataStore managing this FeatureSource

addFeatureListener

public void addFeatureListener(FeatureListener listener)
Adds FeatureListener to the JDBCDataStore against this FeatureSource.

Specified by:
addFeatureListener in interface FeatureSource
Parameters:
listener -
See Also:
FeatureSource.addFeatureListener(org.geotools.data.FeatureListener)

removeFeatureListener

public void removeFeatureListener(FeatureListener listener)
Remove FeatureListener to the JDBCDataStore against this FeatureSource.

Specified by:
removeFeatureListener in interface FeatureSource
Parameters:
listener -
See Also:
FeatureSource.removeFeatureListener(org.geotools.data.FeatureListener)

getTransaction

public Transaction getTransaction()
Retrieve the Transaction this FeatureSource is opperating against.

For a plain JDBCFeatureSource that cannot modify this will always be Transaction.AUTO_COMMIT.

Returns:
DOCUMENT ME!

getFeatures

public FeatureCollection getFeatures(Query request)
                              throws java.io.IOException
Provides an interface to for the Resutls of a Query.

Various queries can be made against the results, the most basic being to retrieve Features.

Specified by:
getFeatures in interface FeatureSource
Parameters:
request -
Returns:
Throws:
java.io.IOException
See Also:
FeatureSource.getFeatures(org.geotools.data.Query)

getFeatures

public FeatureCollection getFeatures(Filter filter)
                              throws java.io.IOException
Retrieve all Feature matching the Filter

Specified by:
getFeatures in interface FeatureSource
Parameters:
filter - DOCUMENT ME!
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

getFeatures

public FeatureCollection getFeatures()
                              throws java.io.IOException
Retrieve all Features

Specified by:
getFeatures in interface FeatureSource
Returns:
DOCUMENT ME!
Throws:
java.io.IOException - DOCUMENT ME!

getBounds

public com.vividsolutions.jts.geom.Envelope getBounds()
                                               throws java.io.IOException
Retrieve Bounds of all Features.

Currently returns null, consider getFeatures().getBounds() instead.

Subclasses may override this method to perform the appropriate optimization for this result.

Specified by:
getBounds in interface FeatureSource
Returns:
null representing the lack of an optimization
Throws:
java.io.IOException - DOCUMENT ME!

getBounds

public com.vividsolutions.jts.geom.Envelope getBounds(Query query)
                                               throws java.io.IOException
Retrieve Bounds of Query results.

Currently returns null, consider getFeatures( query ).getBounds() instead.

Subclasses may override this method to perform the appropriate optimization for this result.

Specified by:
getBounds in interface FeatureSource
Parameters:
query - Query we are requesting the bounds of
Returns:
null representing the lack of an optimization
Throws:
java.io.IOException - DOCUMENT ME!

getCount

public int getCount(Query query)
             throws java.io.IOException
Retrieve total number of Query results.

SQL: SELECT COUNT(*) as cnt FROM table WHERE filter

Specified by:
getCount in interface FeatureSource
Parameters:
query - Query we are requesting the count of
Returns:
Count of indicated query
Throws:
java.io.IOException - if there are errors getting the count

count

public int count(Query query,
                 Transaction transaction)
          throws java.io.IOException
Direct SQL query number of rows in query.

Note this is a low level SQL statment and if it fails the provided Transaction will be rolled back.

SQL: SELECT COUNT(*) as cnt FROM table WHERE filter

Parameters:
query -
transaction -
Returns:
Number of rows in query, or -1 if not optimizable.
Throws:
java.io.IOException - Usual on the basis of a filter error

getSchema

public FeatureType getSchema()
Retrieve FeatureType represented by this FeatureSource

Specified by:
getSchema in interface FeatureSource
Returns:
FeatureType for FeatureSource
See Also:
FeatureSource.getSchema()

getConnection

protected java.sql.Connection getConnection()
                                     throws java.io.IOException
Throws:
java.io.IOException

close

protected void close(java.sql.Connection conn,
                     Transaction trans,
                     java.sql.SQLException sqle)

close

protected void close(java.sql.ResultSet rs)

close

protected void close(java.sql.Statement statement)


Copyright © GeoTools. All Rights Reserved.