org.geotools.data.store
Class ContentFeatureStore

Object
  extended by ContentFeatureSource
      extended by ContentFeatureStore
All Implemented Interfaces:
FeatureLocking<SimpleFeatureType,SimpleFeature>, FeatureSource<SimpleFeatureType,SimpleFeature>, FeatureStore<SimpleFeatureType,SimpleFeature>, SimpleFeatureSource, SimpleFeatureStore
Direct Known Subclasses:
JDBCFeatureStore

public abstract class ContentFeatureStore
extends ContentFeatureSource
implements SimpleFeatureStore, FeatureLocking<SimpleFeatureType,SimpleFeature>

Abstract implementation of FeatureStore.

List its base class ContentFeatureSource, this feature store works off of operations provided by FeatureCollection.

The #addFeatures(SimpleFeatureCollection) method is used to add features to the feature store. The method should return the "persistent" feature id's which are generated after the feature has been added to persistent storage. Often the persistent fid is different from the fid specified by the actual feature being inserted. For this reason Property.getUserData() is used to report back persistent fids. It is up to the implementor of the feature collection to report this value back after a feature has been inserted. As an example, consider an implementation of FeatureCollection#add(Object).

  boolean add( Object o ) {
    SimpleFeature feature = (SimpleFeature) o;
    
    //1.add the feature to storage
    ...
    
    //2. derive the persistent fid
    String fid = ...;
    
    //3. set the user data
    feature.getUserData().put( "fid", fid );
  
  }
 

Author:
Justin Deoliveira, The Open Planning Project

Nested Class Summary
 
Nested classes/interfaces inherited from interface FeatureLocking
FeatureLocking.Response
 
Field Summary
protected  int WRITER_ADD
          writer flags
protected  int WRITER_UPDATE
           
 
Fields inherited from class ContentFeatureSource
entry, hints, lock, query, queryCapabilities, schema, transaction
 
Constructor Summary
ContentFeatureStore(ContentEntry entry, Query query)
          Creates the content feature store.
 
Method Summary
 List<FeatureId> addFeatures(Collection collection)
          Adds a collection of features to the store.
 List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)
          Adds a collection of features to the store.
 FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Filter filter)
          Returns a writer over features specified by a filter.
 FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Filter filter, int flags)
          Returns a writer over features specified by a filter.
 FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Query query)
          Returns a writer over features specified by a query.
 FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Query query, int flags)
          Returns a writer over features specified by a query.
protected abstract  FeatureWriter<SimpleFeatureType,SimpleFeature> getWriterInternal(Query query, int flags)
          Subclass method for returning a native writer from the datastore.
 void modifyFeatures(AttributeDescriptor[] type, Object[] value, Filter filter)
          For backwards compatibility; please be careful that your descriptor is actually compatible with the one declared.
 void modifyFeatures(AttributeDescriptor type, Object value, Filter filter)
          Calls through to modifyFeatures(Name[], Object[], Filter).
 void modifyFeatures(Name[] type, Object[] value, Filter filter)
          Modifies/updates the features of the store which match the specified filter.
 void modifyFeatures(Name name, Object value, Filter filter)
          Calls through to modifyFeatures(Name[], Object[], Filter).
 void modifyFeatures(String[] names, Object[] values, Filter filter)
           
 void modifyFeatures(String name, Object attributeValue, Filter filter)
           
 void removeFeatures(Filter filter)
          Removes the features from the store which match the specified filter.
 void setFeatures(FeatureReader<SimpleFeatureType,SimpleFeature> reader)
          Sets the feature of the source.
 
Methods inherited from class ContentFeatureSource
accepts, addFeatureListener, addHints, buildFeatureType, buildQueryCapabilities, canEvent, canFilter, canLimit, canLock, canOffset, canReproject, canRetype, canSort, canTransact, doLockInternal, doUnlockInternal, getAbsoluteSchema, getBounds, getBounds, getBoundsInternal, getCount, getCountInternal, getDataStore, getEntry, getFeatures, getFeatures, getFeatures, getInfo, getName, getQueryCapabilities, getReader, getReader, getReader, getReaderInternal, getSchema, getState, getSupportedHints, getTransaction, getView, getView, handleVisitor, isView, joinQuery, lockFeatures, lockFeatures, lockFeatures, processLock, removeFeatureListener, resolvePropertyNames, resolvePropertyNames, setFeatureLock, setTransaction, unLockFeatures, unLockFeatures, unLockFeatures
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface SimpleFeatureStore
getFeatures, getFeatures, getFeatures
 
Methods inherited from interface FeatureLocking
lockFeatures, lockFeatures, lockFeatures, setFeatureLock, unLockFeatures, unLockFeatures, unLockFeatures
 
Methods inherited from interface FeatureStore
getTransaction, setTransaction
 
Methods inherited from interface FeatureSource
addFeatureListener, getBounds, getBounds, getCount, getDataStore, getInfo, getName, getQueryCapabilities, getSchema, getSupportedHints, removeFeatureListener
 

Field Detail

WRITER_ADD

protected final int WRITER_ADD
writer flags

See Also:
Constant Field Values

WRITER_UPDATE

protected final int WRITER_UPDATE
See Also:
Constant Field Values
Constructor Detail

ContentFeatureStore

public ContentFeatureStore(ContentEntry entry,
                           Query query)
Creates the content feature store.

Parameters:
entry - The entry for the feature store.
query - The defining query.
Method Detail

getWriter

public final FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Filter filter)
                                                               throws IOException
Returns a writer over features specified by a filter.

Parameters:
filter - The filter
Throws:
IOException

getWriter

public final FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Filter filter,
                                                                      int flags)
                                                               throws IOException
Returns a writer over features specified by a filter.

Parameters:
filter - The filter
flags - flags specifying writing mode
Throws:
IOException

getWriter

public final FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Query query)
                                                               throws IOException
Returns a writer over features specified by a query.

Parameters:
query - The query
Throws:
IOException

getWriter

public final FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Query query,
                                                                      int flags)
                                                               throws IOException
Returns a writer over features specified by a query.

Parameters:
query - The query
flags - flags specifying writing mode
Throws:
IOException

getWriterInternal

protected abstract FeatureWriter<SimpleFeatureType,SimpleFeature> getWriterInternal(Query query,
                                                                                    int flags)
                                                                             throws IOException
Subclass method for returning a native writer from the datastore.

It is important to note that if the native writer intends to handle any of the following natively:

Then it *must* set the corresponding flags to true:

Throws:
IOException

addFeatures

public List<FeatureId> addFeatures(Collection collection)
                            throws IOException
Adds a collection of features to the store.

This method operates by getting an appending feature writer and writing all the features in collection to it. Directly after a feature is written its id is obtained and added to the returned set.

Throws:
IOException

addFeatures

public List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection)
                            throws IOException
Adds a collection of features to the store.

This method calls through to addFeatures(Collection).

Specified by:
addFeatures in interface FeatureStore<SimpleFeatureType,SimpleFeature>
Parameters:
featureCollection -
Returns:
the FeatureIds of the newly added features
Throws:
IOException - if an error occurs modifying the data source

setFeatures

public final void setFeatures(FeatureReader<SimpleFeatureType,SimpleFeature> reader)
                       throws IOException
Sets the feature of the source.

This method operates by first clearing the contents of the feature store (removeFeatures(Filter)), and then obtaining an appending feature writer and writing all features from reader to it.

Specified by:
setFeatures in interface FeatureStore<SimpleFeatureType,SimpleFeature>
Parameters:
reader - - the collection to be written
Throws:
IOException - if there are any datasource errors.

modifyFeatures

public void modifyFeatures(AttributeDescriptor[] type,
                           Object[] value,
                           Filter filter)
                    throws IOException
Description copied from interface: FeatureStore
For backwards compatibility; please be careful that your descriptor is actually compatible with the one declared.

Specified by:
modifyFeatures in interface FeatureStore<SimpleFeatureType,SimpleFeature>
Parameters:
type - the attributes to modify
value - the new values for the attributes
filter - an OpenGIS filter
Throws:
IOException

modifyFeatures

public void modifyFeatures(Name[] type,
                           Object[] value,
                           Filter filter)
                    throws IOException
Modifies/updates the features of the store which match the specified filter.

This method operates by obtaining an updating feature writer based on the specified filter and writing the updated values to it.

The filter must not be null, in this case this method will throw an IllegalArgumentException.

Specified by:
modifyFeatures in interface FeatureStore<SimpleFeatureType,SimpleFeature>
Parameters:
type - the attributes to modify
value - the new values for the attributes
filter - an OpenGIS filter
Throws:
IOException - if the attribute and object arrays are not equal in length; if the value types do not match the attribute types; if modification is not supported; or if there errors accessing the data source

modifyFeatures

public final void modifyFeatures(String name,
                                 Object attributeValue,
                                 Filter filter)
                          throws IOException
Specified by:
modifyFeatures in interface SimpleFeatureStore
Throws:
IOException

modifyFeatures

public final void modifyFeatures(String[] names,
                                 Object[] values,
                                 Filter filter)
                          throws IOException
Specified by:
modifyFeatures in interface SimpleFeatureStore
Throws:
IOException

modifyFeatures

public final void modifyFeatures(AttributeDescriptor type,
                                 Object value,
                                 Filter filter)
                          throws IOException
Calls through to modifyFeatures(Name[], Object[], Filter).

Specified by:
modifyFeatures in interface FeatureStore<SimpleFeatureType,SimpleFeature>
Parameters:
type - the attribute to modify
value - the new value for the attribute
filter - an OpenGIS filter
Throws:
IOException

modifyFeatures

public final void modifyFeatures(Name name,
                                 Object value,
                                 Filter filter)
                          throws IOException
Calls through to modifyFeatures(Name[], Object[], Filter).

Specified by:
modifyFeatures in interface FeatureStore<SimpleFeatureType,SimpleFeature>
Parameters:
name - the attribute to modify
value - the new value for the attribute
filter - an OpenGIS filter
Throws:
IOException - if modification is not supported; if the value type does not match the attribute type; or if there errors accessing the data source

removeFeatures

public void removeFeatures(Filter filter)
                    throws IOException
Removes the features from the store which match the specified filter.

This method operates by obtaining an updating feature writer based on the specified filter and removing every feature from it.

The filter must not be null, in this case this method will throw an IllegalArgumentException.

Specified by:
removeFeatures in interface FeatureStore<SimpleFeatureType,SimpleFeature>
Parameters:
filter - an OpenGIS filter
Throws:
IOException - if an error occurs modifying the data source


Copyright © 1996-2014 Geotools. All Rights Reserved.