org.geotools.data.view
Class DefaultView

java.lang.Object
  extended byorg.geotools.data.view.DefaultView
All Implemented Interfaces:
FeatureSource

public class DefaultView
extends java.lang.Object
implements FeatureSource

Wrapper for FeatureSource constrained by a Query.

Support FeatureSource decorator that takes care of mapping a Query & 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?

WARNING: this class is a placeholder for ideas right now - it may not always impement FeatureSource.

Author:
Gabriel Rold?n

Field Summary
protected  FeatureSource source
          FeatureSource being served up
 
Constructor Summary
DefaultView(FeatureSource source, Query query)
          Creates a new GeoServerFeatureSource object.
 
Method Summary
 void addFeatureListener(FeatureListener listener)
          Implement addFeatureListener.
static FeatureSource create(FeatureSource source, Query query)
          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(Query query)
          Retrive the extent of the Query.
 int getCount(Query query)
          Adjust query and forward to source.
 DataStore getDataStore()
          Implement getDataStore.
 FeatureCollection getFeatures()
          Implement getFeatures.
 FeatureCollection getFeatures(Filter filter)
          Implement getFeatures.
 FeatureCollection getFeatures(Query query)
          Implement getFeatures.
 FeatureType getSchema()
          Implement getSchema.
protected  Filter makeDefinitionFilter(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  DefaultQuery makeDefinitionQuery(Query query)
          Takes a query and adapts it to match re definitionQuery filter configured for a feature type.
 void removeFeatureListener(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 FeatureSource source
FeatureSource being served up

Constructor Detail

DefaultView

public DefaultView(FeatureSource source,
                   Query query)
            throws SchemaException
Creates a new GeoServerFeatureSource object.

Grabs the following from query:

Schema is generated based on this information.

Parameters:
source - GeoTools2 FeatureSource
Throws:
SchemaException
Method Detail

create

public static FeatureSource create(FeatureSource source,
                                   Query query)
                            throws SchemaException
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.

TODO: revisit this - I am not sure I want write access to views (especially if they do reprojection).

Returns:
@throws SchemaException
Throws:
SchemaException

makeDefinitionQuery

protected DefaultQuery makeDefinitionQuery(Query query)
                                    throws java.io.IOException
Takes a query and adapts it to match re definitionQuery filter configured for a feature type. It won't handle coordinate system changes

Grabs the following from query:

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

makeDefinitionFilter

protected Filter makeDefinitionFilter(Filter filter)
                               throws 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:
DataSourceException - If the filter could not meet the limitations of definitionQuery

getDataStore

public DataStore getDataStore()
Implement getDataStore.

Description ...

Specified by:
getDataStore in interface FeatureSource
Returns:
@see org.geotools.data.FeatureSource#getDataStore()

addFeatureListener

public void addFeatureListener(FeatureListener listener)
Implement addFeatureListener.

Description ...

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

removeFeatureListener

public void removeFeatureListener(FeatureListener listener)
Implement removeFeatureListener.

Description ...

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

getFeatures

public FeatureCollection getFeatures(Query query)
                              throws java.io.IOException
Implement getFeatures.

Description ...

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

getFeatures

public FeatureCollection getFeatures(Filter filter)
                              throws java.io.IOException
Implement getFeatures.

Description ...

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

getFeatures

public FeatureCollection getFeatures()
                              throws java.io.IOException
Implement getFeatures.

Description ...

Specified by:
getFeatures in interface FeatureSource
Returns:
@throws IOException
Throws:
java.io.IOException - For all data source errors.
See Also:
FeatureSource.getFeatures()

getSchema

public FeatureType getSchema()
Implement getSchema.

Description ...

Specified by:
getSchema in interface FeatureSource
Returns:
@see org.geotools.data.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 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(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 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(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 FeatureSource
Parameters:
query - User's query.
Returns:
Number of Features for Query, or -1 if no optimization is available.


Copyright © GeoTools. All Rights Reserved.