Package org.geotools.api.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:
ContentFeatureStore
,CSVFeatureStore
,DirectoryFeatureLocking
,DirectoryFeatureStore
,GeoJSONFeatureStore
,JDBCFeatureStore
,MemoryFeatureStore
,MongoFeatureStore
,OracleTransformFeatureStore
,PostgisTransformFeatureStore
,PropertyFeatureStore
,SQLServerTransformFeatureStore
,TransformFeatureLocking
,TransformFeatureStore
public interface FeatureStore<T extends FeatureType,F extends Feature> extends FeatureSource<T,F>
This interface extendsFeatureSource
, 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) { java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", ex); t.rollback(); } finally { t.close(); } }
- Author:
- Jody Garnett, Ray Gallagher, Rob Hranac, TOPP, Chris Holmes, TOPP
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description List<FeatureId>
addFeatures(FeatureCollection<T,F> featureCollection)
Adds all features from the feature collection.Transaction
getTransaction()
Gets theTransaction
that thisFeatureStore
is currently operating against.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 thisFeatureStore
.-
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 modifyattributeValues
- the new values for the attributesfilter
- 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(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 modifyattributeValue
- the new value for the attributefilter
- 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
-
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 thisFeatureStore
.Transaction t = new DefaultTransaction(); featureStore.setTransaction(t); try { featureStore.addFeatures( someFeatures ); t.commit(); } catch ( IOException ex ) { // something went wrong; java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", ex); t.rollback(); } finally { t.close(); }
- Parameters:
transaction
- the transaction
-
getTransaction
Transaction getTransaction()
Gets theTransaction
that thisFeatureStore
is currently operating against.Transaction t = featureStore.getTransaction(); try { featureStore.addFeatures( features ); t.commit(); } catch( IOException erp ){ // something went wrong; java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", ex); t.rollback(); }
- Returns:
- Transaction in use, or Transaction.AUTO_COMMIT
-
-