org.geotools.data
Class AbstractFeatureSource

Object
  extended by AbstractFeatureSource
All Implemented Interfaces:
FeatureSource<SimpleFeatureType,SimpleFeature>
Direct Known Subclasses:
AbstractFeatureStore, WFSFeatureSource

public abstract class AbstractFeatureSource
extends Object
implements FeatureSource<SimpleFeatureType,SimpleFeature>

This is a starting point for providing your own FeatureSource implementation.

Subclasses must implement:

You may find a FeatureSource implementations that is more specific to your needs - such as JDBCFeatureSource.

For an example of this class customized for use please see MemoryDataStore.

Author:
Jody Garnett, Refractions Research Inc
Module:

Field Summary
protected  Set hints
           
protected  QueryCapabilities queryCapabilities
           
 
Constructor Summary
AbstractFeatureSource()
           
AbstractFeatureSource(Set hints)
          This constructors allows to set the supported hints
 
Method Summary
 ReferencedEnvelope getBounds()
          Retrieve Bounds of all Features.
 ReferencedEnvelope getBounds(Query query)
          Retrieve Bounds of Query results.
 int getCount(Query query)
          Retrieve total number of Query results.
abstract  DataStore getDataStore()
          Overrides to explicitly type narrow the return type to DataStore
 FeatureCollection<SimpleFeatureType,SimpleFeature> getFeatures()
          Retrieve all Features.
 FeatureCollection<SimpleFeatureType,SimpleFeature> getFeatures(Filter filter)
          Retrieve all Feature matching the Filter.
 FeatureCollection<SimpleFeatureType,SimpleFeature> getFeatures(Query query)
          Provides an interface to for the Results of a Query.
 ResourceInfo getInfo()
          Information describing the contents of this resoruce.
 Name getName()
          Returns the same name than the feature type (ie, getSchema().getName() to honor the simple feature land common practice of calling the same both the Features produces and their types
 QueryCapabilities getQueryCapabilities()
          Returns and indication of what query capabilities this FeatureSource supports natively.
 Set getSupportedHints()
          By default, no Hints are supported
 Transaction getTransaction()
          Retrieve the Transaction this FeatureSource is operating against.
protected  Query namedQuery(Query query)
          Ensure query modified with typeName.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface FeatureSource
addFeatureListener, getSchema, removeFeatureListener
 

Field Detail

hints

protected Set hints

queryCapabilities

protected QueryCapabilities queryCapabilities
Constructor Detail

AbstractFeatureSource

public AbstractFeatureSource()

AbstractFeatureSource

public AbstractFeatureSource(Set hints)
This constructors allows to set the supported hints

Parameters:
hints -
Method Detail

getDataStore

public abstract DataStore getDataStore()
Overrides to explicitly type narrow the return type to DataStore

Specified by:
getDataStore in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Returns:
DataStore implementing this FeatureStore

getName

public Name getName()
Returns the same name than the feature type (ie, getSchema().getName() to honor the simple feature land common practice of calling the same both the Features produces and their types

Specified by:
getName in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Returns:
the name of the AttributeDescriptor for the Features served by this FeatureSource
Since:
2.5
See Also:
FeatureSource.getName()

getInfo

public ResourceInfo getInfo()
Description copied from interface: FeatureSource
Information describing the contents of this resoruce.

Please note that for FeatureContent:


getQueryCapabilities

public QueryCapabilities getQueryCapabilities()
Description copied from interface: FeatureSource
Returns and indication of what query capabilities this FeatureSource supports natively.

Specified by:
getQueryCapabilities in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Returns:
a QueryCapabilities object containing the native query capabilities.

getTransaction

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

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

Returns:
Transacstion FeatureSource is operating against

getFeatures

public FeatureCollection<SimpleFeatureType,SimpleFeature> getFeatures(Query query)
                                                               throws IOException
Provides an interface to for the Results of a Query.

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

Specified by:
getFeatures in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Parameters:
query -
Returns:
Collection The collection to put the features into.
Throws:
IOException - For all data source errors.
See Also:
FeatureSource.getFeatures(org.geotools.data.Query)

getFeatures

public FeatureCollection<SimpleFeatureType,SimpleFeature> getFeatures(Filter filter)
                                                               throws IOException
Retrieve all Feature matching the Filter.

Specified by:
getFeatures in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Parameters:
filter - Indicates features to retrieve
Returns:
FeatureResults indicating features matching filter
Throws:
IOException - If results could not be obtained

getFeatures

public FeatureCollection<SimpleFeatureType,SimpleFeature> getFeatures()
                                                               throws IOException
Retrieve all Features.

Specified by:
getFeatures in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Returns:
FeatureResults of all Features in FeatureSource
Throws:
IOException - If features could not be obtained

getBounds

public ReferencedEnvelope getBounds()
                             throws 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<SimpleFeatureType,SimpleFeature>
Returns:
null representing the lack of an optimization
Throws:
IOException - DOCUMENT ME!

getBounds

public ReferencedEnvelope getBounds(Query query)
                             throws 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<SimpleFeatureType,SimpleFeature>
Parameters:
query - Query we are requesting the bounds of
Returns:
null representing the lack of an optimization
Throws:
IOException - DOCUMENT ME!

namedQuery

protected Query namedQuery(Query query)
Ensure query modified with typeName.

This method will make copy of the provided query, using DefaultQuery, if query.getTypeName is not equal to getSchema().getTypeName().

Parameters:
query - Original query
Returns:
Query with getTypeName() equal to getSchema().getTypeName()

getCount

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

Currently returns -1, consider getFeatures( query ).getCount() instead.

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

Specified by:
getCount in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Parameters:
query - Query we are requesting the count of
Returns:
-1 representing the lack of an optimization
Throws:
IOException - if there are errors getting the count

getSupportedHints

public Set getSupportedHints()
By default, no Hints are supported

Specified by:
getSupportedHints in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Returns:
a set of RenderingHints#Key objects (eventually empty, never null).


Copyright © 1996-2009 Geotools. All Rights Reserved.