org.vfny.geoserver.global
Class GeoServerFeatureSource

java.lang.Object
  extended byorg.vfny.geoserver.global.GeoServerFeatureSource
All Implemented Interfaces:
org.geotools.data.FeatureSource
Direct Known Subclasses:
GeoServerFeatureStore

public class GeoServerFeatureSource
extends java.lang.Object
implements org.geotools.data.FeatureSource

GeoServer wrapper for backend Geotools2 DataStore.

Support FeatureSource decorator for FeatureTypeInfo that takes care of mapping the FeatureTypeInfo's FeatureSource with the schema and definition query configured for it.

Because GeoServer requires that attributes always be returned in the same order we need a way to smoothly inforce this. Could we use this class to do so?


Field Summary
protected  org.geotools.data.FeatureSource source
          FeatureSource being served up
 
Method Summary
 void addFeatureListener(org.geotools.data.FeatureListener listener)
          Implement addFeatureListener.
static GeoServerFeatureSource create(org.geotools.data.FeatureSource featureSource, org.geotools.feature.FeatureType schema, org.geotools.filter.Filter definitionQuery)
          Factory that make the correct decorator for the provided featureSource.
 com.vividsolutions.jts.geom.Envelope getBounds()
          Retrieves the total extent of this FeatureSource.
 com.vividsolutions.jts.geom.Envelope getBounds(org.geotools.data.Query query)
          Retrive the extent of the Query.
 int getCount(org.geotools.data.Query query)
          Adjust query and forward to source.
 org.geotools.data.DataStore getDataStore()
          Implement getDataStore.
 org.geotools.data.FeatureResults getFeatures()
          Implement getFeatures.
 org.geotools.data.FeatureResults getFeatures(org.geotools.filter.Filter filter)
          Implement getFeatures.
 org.geotools.data.FeatureResults getFeatures(org.geotools.data.Query query)
          Implement getFeatures.
 org.geotools.feature.FeatureType getSchema()
          Implement getSchema.
protected  org.geotools.filter.Filter makeDefinitionFilter(org.geotools.filter.Filter filter)
          If a definition query has been configured for the FeatureTypeInfo, makes and return a new Filter that contains both the query's filter and the layer's definition one, by logic AND'ing them.
protected  org.geotools.data.Query makeDefinitionQuery(org.geotools.data.Query query)
          Takes a query and adapts it to match re definitionQuery filter configured for a feature type.
 void removeFeatureListener(org.geotools.data.FeatureListener listener)
          Implement removeFeatureListener.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

source

protected org.geotools.data.FeatureSource source
FeatureSource being served up

Method Detail

create

public static GeoServerFeatureSource create(org.geotools.data.FeatureSource featureSource,
                                            org.geotools.feature.FeatureType schema,
                                            org.geotools.filter.Filter definitionQuery)
Factory that make the correct decorator for the provided featureSource.

This factory method is public and will be used to create all required subclasses. By comparison the constructors for this class have package visibiliy.

Parameters:
featureSource -
schema - DOCUMENT ME!
definitionQuery - DOCUMENT ME!
Returns:

makeDefinitionQuery

protected org.geotools.data.Query makeDefinitionQuery(org.geotools.data.Query query)
                                               throws java.io.IOException
Takes a query and adapts it to match re definitionQuery filter configured for a feature type.

Parameters:
query - Query against this DataStore
Returns:
Query restricted to the limits of definitionQuery
Throws:
java.io.IOException - See DataSourceException
org.geotools.data.DataSourceException - If query could not meet the restrictions of definitionQuery

makeDefinitionFilter

protected org.geotools.filter.Filter makeDefinitionFilter(org.geotools.filter.Filter filter)
                                                   throws org.geotools.data.DataSourceException
If a definition query has been configured for the FeatureTypeInfo, makes and return a new Filter that contains both the query's filter and the layer's definition one, by logic AND'ing them.

Parameters:
filter - Origional user supplied Filter
Returns:
Filter adjusted to the limitations of definitionQuery
Throws:
org.geotools.data.DataSourceException - If the filter could not meet the limitations of definitionQuery

getDataStore

public org.geotools.data.DataStore getDataStore()
Implement getDataStore.

Description ...

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

addFeatureListener

public void addFeatureListener(org.geotools.data.FeatureListener listener)
Implement addFeatureListener.

Description ...

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

removeFeatureListener

public void removeFeatureListener(org.geotools.data.FeatureListener listener)
Implement removeFeatureListener.

Description ...

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

getFeatures

public org.geotools.data.FeatureResults getFeatures(org.geotools.data.Query query)
                                             throws java.io.IOException
Implement getFeatures.

Description ...

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

getFeatures

public org.geotools.data.FeatureResults getFeatures(org.geotools.filter.Filter filter)
                                             throws java.io.IOException
Implement getFeatures.

Description ...

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

getFeatures

public org.geotools.data.FeatureResults getFeatures()
                                             throws java.io.IOException
Implement getFeatures.

Description ...

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

getSchema

public org.geotools.feature.FeatureType getSchema()
Implement getSchema.

Description ...

Specified by:
getSchema in interface org.geotools.data.FeatureSource
Returns:
See Also:
FeatureSource.getSchema()

getBounds

public com.vividsolutions.jts.geom.Envelope getBounds()
                                               throws java.io.IOException
Retrieves the total extent of this FeatureSource.

Please note this extent will reflect the provided definitionQuery.

Specified by:
getBounds in interface org.geotools.data.FeatureSource
Returns:
Extent of this FeatureSource, or null if no optimizations exist.
Throws:
java.io.IOException - If bounds of definitionQuery

getBounds

public com.vividsolutions.jts.geom.Envelope getBounds(org.geotools.data.Query query)
                                               throws java.io.IOException
Retrive the extent of the Query.

This method provides access to an optimized getBounds opperation. If no optimized opperation is available null will be returned.

You may still make use of getFeatures( Query ).getCount() which will return the correct answer (even if it has to itterate through all the results to do so.

Specified by:
getBounds in interface org.geotools.data.FeatureSource
Parameters:
query - User's query
Returns:
Extend of Query or null if no optimization is available
Throws:
java.io.IOException - If a problem is encountered with source

getCount

public int getCount(org.geotools.data.Query query)
Adjust query and forward to source.

This method provides access to an optimized getCount opperation. If no optimized opperation is available -1 will be returned.

You may still make use of getFeatures( Query ).getCount() which will return the correct answer (even if it has to itterate through all the results to do so).

Specified by:
getCount in interface org.geotools.data.FeatureSource
Parameters:
query - User's query.
Returns:
Number of Features for Query, or -1 if no optimization is available.