org.geotools.data
Interface FeatureStore<T extends FeatureType,F extends Feature>

All Superinterfaces:
FeatureSource<T,F>
All Known Subinterfaces:
FeatureLocking<T,F>, SimpleFeatureLocking, SimpleFeatureStore
All Known Implementing Classes:
AbstractFeatureLocking, AbstractFeatureStore, ArcSdeFeatureStore, ContentFeatureStore, DirectoryFeatureLocking, DirectoryFeatureStore, JDBCFeatureStore, OracleTransformFeatureStore, PropertyFeatureStore, TransformFeatureStore, WFSFeatureStore

public interface FeatureStore<T extends FeatureType,F extends Feature>
extends FeatureSource<T,F>

This interface extends FeatureSource, adding methods to add and remove features and to modify existing features.


 DataStore myDataStore = ...
 FeatureSource featureSource = myDataStore.getFeatureSource("aname");
 if (featureSource instanceof FeatureStore) {
     // we have write access to the feature data
     FeatureStore featureStore = (FeatureStore) featureSource;

     // add some new features
     Transaction t = new DefaultTransaction("add");
     featureStore.setTransaction(t);
     try {
         featureStore.addFeatures( someFeatures );
         t.commit();
     } catch (Exception ex) {
         ex.printStackTrace();
         t.rollback();
     } finally {
         t.close();
     }
 }
 

Author:
Jody Garnett, Ray Gallagher, Rob Hranac, TOPP, Chris Holmes, TOPP

Method Summary
 List<FeatureId> addFeatures(FeatureCollection<T,F> featureCollection)
          Adds all features from the feature collection.
 Transaction getTransaction()
          Gets the Transaction that this FeatureStore is currently operating against.
 void modifyFeatures(AttributeDescriptor[] type, Object[] value, Filter filter)
          Deprecated. Please use the safer method modifyFeatures(Name[], Object[], Filter)
 void modifyFeatures(AttributeDescriptor type, Object value, Filter filter)
          Deprecated. Please use the safer method modifyFeatures(Name, Object, Filter)
 void modifyFeatures(Name[] attributeNames, Object[] attributeValues, Filter filter)
          Modifies the attributes with the supplied values in all features selected by the given filter.
 void modifyFeatures(Name attributeName, Object attributeValue, Filter filter)
          Modifies an attribute with the supplied value in all features selected by the given filter.
 void removeFeatures(Filter filter)
          Removes features selected by the given filter.
 void setFeatures(FeatureReader<T,F> reader)
          Deletes any existing features in the data source and then inserts new features provided by the given reader.
 void setTransaction(Transaction transaction)
          Provide a transaction for commit/rollback control of a modifying operation on this FeatureStore.
 
Methods inherited from interface FeatureSource
addFeatureListener, getBounds, getBounds, getCount, getDataStore, getFeatures, getFeatures, getFeatures, getInfo, getName, getQueryCapabilities, getSchema, getSupportedHints, removeFeatureListener
 

Method Detail

addFeatures

List<FeatureId> addFeatures(FeatureCollection<T,F> featureCollection)
                            throws IOException
Adds all features from the feature collection.

A list of FeatureIds is returned, one for each feature in the order created. However, these might not be assigned until after a commit has been performed.

Parameters:
featureCollection - the collection of features to add
Returns:
the FeatureIds of the newly added features
Throws:
IOException - if an error occurs modifying the data source

removeFeatures

void removeFeatures(Filter filter)
                    throws IOException
Removes features selected by the given filter.

Parameters:
filter - an OpenGIS filter
Throws:
IOException - if an error occurs modifying the data source

modifyFeatures

void modifyFeatures(Name[] attributeNames,
                    Object[] attributeValues,
                    Filter filter)
                    throws IOException
Modifies the attributes with the supplied values in all features selected by the given filter.

Parameters:
attributeNames - the attributes to modify
attributeValues - 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

void modifyFeatures(AttributeDescriptor[] type,
                    Object[] value,
                    Filter filter)
                    throws IOException
Deprecated. Please use the safer method modifyFeatures(Name[], Object[], Filter)

For backwards compatibility; please be careful that your descriptor is actually compatible with the one declared.

Parameters:
type - the attributes to modify
value - the new values for the attributes
filter - an OpenGIS filter
Throws:
IOException

modifyFeatures

void modifyFeatures(Name attributeName,
                    Object attributeValue,
                    Filter filter)
                    throws IOException
Modifies an attribute with the supplied value in all features selected by the given filter.

Parameters:
attributeName - the attribute to modify
attributeValue - 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

modifyFeatures

void modifyFeatures(AttributeDescriptor type,
                    Object value,
                    Filter filter)
                    throws IOException
Deprecated. Please use the safer method modifyFeatures(Name, Object, Filter)

For backwards compatibility; please be careful that your descriptor is actually compatible with the one declared.

Parameters:
type - the attribute to modify
value - the new value for the attribute
filter - an OpenGIS filter
Throws:
IOException

setFeatures

void setFeatures(FeatureReader<T,F> reader)
                 throws IOException
Deletes any existing features in the data source and then inserts new features provided by the given reader. This is primarily used as a convenience method for file-based data sources.

Parameters:
reader - - the collection to be written
Throws:
IOException - if there are any datasource errors.

setTransaction

void setTransaction(Transaction transaction)
Provide a transaction for commit/rollback control of a modifying operation on this FeatureStore.

 Transation t = new DefaultTransaction();
 featureStore.setTransaction(t);
 try {
     featureStore.addFeatures( someFeatures );
     t.commit();
 } catch ( IOException ex ) {
     // something went wrong;
     ex.printStackTrace();
     t.rollback();
 } finally {
     t.close();
 }
 

Parameters:
transaction - the transaction

getTransaction

Transaction getTransaction()
Gets the Transaction that this FeatureStore is currently operating against.

 Transaction t = featureStore.getTransaction();
 try {
     featureStore.addFeatures( features );
     t.commit();
 } catch( IOException erp ){
     // something went wrong;
     ex.printStackTrace();
     t.rollback();
 }
 

Returns:
Transaction in use, or Transaction.AUTO_COMMIT


Copyright © 1996-2014 Geotools. All Rights Reserved.