public interface FeatureStore<T extends FeatureType,F extends Feature> extends FeatureSource<T,F>
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) {
java.util.logging.Logger.getGlobal().log(java.util.logging.Level.INFO, "", ex);
t.rollback();
} finally {
t.close();
}
}
Modifier and Type | Method and Description |
---|---|
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 . |
addFeatureListener, getBounds, getBounds, getCount, getDataStore, getFeatures, getFeatures, getFeatures, getInfo, getName, getQueryCapabilities, getSchema, getSupportedHints, removeFeatureListener
List<FeatureId> addFeatures(FeatureCollection<T,F> featureCollection) throws IOException
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.
featureCollection
- the collection of features to addFeatureIds
of the newly added featuresIOException
- if an error occurs modifying the data sourcevoid removeFeatures(Filter filter) throws IOException
filter
- an OpenGIS filterIOException
- if an error occurs modifying the data sourcevoid modifyFeatures(Name[] attributeNames, Object[] attributeValues, Filter filter) throws IOException
attributeNames
- the attributes to modifyattributeValues
- the new values for the attributesfilter
- an OpenGIS filterIOException
- 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 sourcevoid modifyFeatures(AttributeDescriptor[] type, Object[] value, Filter filter) throws IOException
modifyFeatures(Name[], Object[], Filter)
type
- the attributes to modifyvalue
- the new values for the attributesfilter
- an OpenGIS filterIOException
void modifyFeatures(Name attributeName, Object attributeValue, Filter filter) throws IOException
attributeName
- the attribute to modifyattributeValue
- the new value for the attributefilter
- an OpenGIS filterIOException
- if modification is not supported; if the value type does not match the
attribute type; or if there errors accessing the data sourcevoid modifyFeatures(AttributeDescriptor type, Object value, Filter filter) throws IOException
modifyFeatures(Name, Object, Filter)
type
- the attribute to modifyvalue
- the new value for the attributefilter
- an OpenGIS filterIOException
void setFeatures(FeatureReader<T,F> reader) throws IOException
reader
- - the collection to be writtenIOException
- if there are any datasource errors.void setTransaction(Transaction transaction)
FeatureStore
.
Transation 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();
}
transaction
- the transactionTransaction getTransaction()
Transaction
that this FeatureStore
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();
}
Copyright © 1996–2019 Geotools. All rights reserved.