org.geotools.data
Class AbstractFeatureSource

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

public abstract class AbstractFeatureSource
extends Object
implements SimpleFeatureSource

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

Subclasses must implement:

You may find a SimpleFeatureSource 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

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
 SimpleFeatureCollection getFeatures()
          Retrieve all Features.
 SimpleFeatureCollection getFeatures(Filter filter)
          Retrieve all Feature matching the Filter.
 SimpleFeatureCollection getFeatures(Query query)
          Provides an interface to for the Results of a Query.
 ResourceInfo getInfo()
          Returns information describing this FeatureSource which may include title, description and spatial parameters.
 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()
          Enquire what what query capabilities this FeatureSource natively supports.
 Set getSupportedHints()
          By default, no Hints are supported
 Transaction getTransaction()
          Retrieve the Transaction this SimpleFeatureSource 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:
the data source providing this FeatureSource

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 features accessible through this FeatureSource
Since:
2.5
See Also:
FeatureSource.getName()

getInfo

public ResourceInfo getInfo()
Description copied from interface: FeatureSource
Returns information describing this FeatureSource which may include title, description and spatial parameters. Note that in the returned ResourceInfo object, the distinction between feature name and schema (feature type) name applies as discussed for FeatureSource.getName().

Specified by:
getInfo in interface FeatureSource<SimpleFeatureType,SimpleFeature>

getQueryCapabilities

public QueryCapabilities getQueryCapabilities()
Description copied from interface: FeatureSource
Enquire what what query capabilities this FeatureSource natively supports. For example, whether queries can return sorted results.

Specified by:
getQueryCapabilities in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Returns:
the native query capabilities of this FeatureSource

getTransaction

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

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

Returns:
Transacstion SimpleFeatureSource is operating against

getFeatures

public SimpleFeatureCollection 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>
Specified by:
getFeatures in interface SimpleFeatureSource
Parameters:
query -
Returns:
features retrieved by the Query
Throws:
IOException - if the underlying data source cannot be accessed.
See Also:
FeatureSource.getFeatures(org.geotools.data.Query)

getFeatures

public SimpleFeatureCollection getFeatures(Filter filter)
                                    throws IOException
Retrieve all Feature matching the Filter.

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

getFeatures

public SimpleFeatureCollection getFeatures()
                                    throws IOException
Retrieve all Features.

Specified by:
getFeatures in interface FeatureSource<SimpleFeatureType,SimpleFeature>
Specified by:
getFeatures in interface SimpleFeatureSource
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

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; may be empty but never null
See Also:
Hints.FEATURE_DETACHED, Hints.JTS_GEOMETRY_FACTORY, Hints.JTS_COORDINATE_SEQUENCE_FACTORY, Hints.JTS_PRECISION_MODEL, Hints.JTS_SRID, Hints.GEOMETRY_DISTANCE, Hints.FEATURE_2D


Copyright © 1996-2014 Geotools. All Rights Reserved.