public abstract class ContentFeatureStore extends ContentFeatureSource implements SimpleFeatureStore, SimpleFeatureLocking
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 ); }
FeatureLocking.Response
Modifier and Type | Field and Description |
---|---|
static String |
ORIGINAL_FEATURE_KEY |
protected int |
WRITER_ADD
Flag writer for adding new content
|
protected int |
WRITER_COMMIT
Flag writer for commit (AUTO_COMMIT with no events)
|
protected int |
WRITER_UPDATE
Flag writer for updating content in place
|
entry, hints, lock, query, queryCapabilities, schema, transaction
Constructor and Description |
---|
ContentFeatureStore(ContentEntry entry,
Query query)
Creates the content feature store.
|
Modifier and Type | Method and Description |
---|---|
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.
|
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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getFeatures, getFeatures, getFeatures
lockFeatures, lockFeatures, lockFeatures, setFeatureLock, unLockFeatures, unLockFeatures, unLockFeatures
getTransaction, setTransaction
addFeatureListener, getBounds, getBounds, getCount, getDataStore, getInfo, getName, getQueryCapabilities, getSchema, getSupportedHints, removeFeatureListener
protected final int WRITER_ADD
protected final int WRITER_UPDATE
protected final int WRITER_COMMIT
public static final String ORIGINAL_FEATURE_KEY
public ContentFeatureStore(ContentEntry entry, Query query)
entry
- The entry for the feature store.query
- The defining query.public final FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Filter filter) throws IOException
filter
- The filterIOException
public final FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Filter filter, int flags) throws IOException
filter
- The filterflags
- flags specifying writing modeIOException
public final FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Query query) throws IOException
query
- The queryIOException
public final FeatureWriter<SimpleFeatureType,SimpleFeature> getWriter(Query query, int flags) throws IOException
query
- The queryflags
- flags specifying writing modeIOException
protected abstract FeatureWriter<SimpleFeatureType,SimpleFeature> getWriterInternal(Query query, int flags) throws IOException
It is important to note that if the native writer intends to handle any of the following natively:
true
:
query
- Queryflags
- See WRITER_ADD
and WRITER_UPDATE
IOException
public List<FeatureId> addFeatures(Collection collection) throws IOException
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.
IOException
public List<FeatureId> addFeatures(FeatureCollection<SimpleFeatureType,SimpleFeature> featureCollection) throws IOException
addFeatures
in interface FeatureStore<SimpleFeatureType,SimpleFeature>
featureCollection
- FeatureIds
of the newly added featuresIOException
- if an error occurs modifying the data sourcepublic final void setFeatures(FeatureReader<SimpleFeatureType,SimpleFeature> reader) throws IOException
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.
setFeatures
in interface FeatureStore<SimpleFeatureType,SimpleFeature>
reader
- - the collection to be writtenIOException
- if there are any datasource errors.public void modifyFeatures(AttributeDescriptor[] type, Object[] value, Filter filter) throws IOException
FeatureStore
modifyFeatures
in interface FeatureStore<SimpleFeatureType,SimpleFeature>
type
- the attributes to modifyvalue
- the new values for the attributesfilter
- an OpenGIS filterIOException
public void modifyFeatures(Name[] type, Object[] value, Filter filter) throws IOException
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
.
modifyFeatures
in interface FeatureStore<SimpleFeatureType,SimpleFeature>
type
- the attributes to modifyvalue
- 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 sourcepublic final void modifyFeatures(String name, Object attributeValue, Filter filter) throws IOException
modifyFeatures
in interface SimpleFeatureStore
IOException
public final void modifyFeatures(String[] names, Object[] values, Filter filter) throws IOException
modifyFeatures
in interface SimpleFeatureStore
IOException
public final void modifyFeatures(AttributeDescriptor type, Object value, Filter filter) throws IOException
modifyFeatures(Name[], Object[], Filter)
.modifyFeatures
in interface FeatureStore<SimpleFeatureType,SimpleFeature>
type
- the attribute to modifyvalue
- the new value for the attributefilter
- an OpenGIS filterIOException
public final void modifyFeatures(Name name, Object value, Filter filter) throws IOException
modifyFeatures(Name[], Object[], Filter)
.modifyFeatures
in interface FeatureStore<SimpleFeatureType,SimpleFeature>
name
- the attribute to modifyvalue
- 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 sourcepublic void removeFeatures(Filter filter) throws IOException
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
.
removeFeatures
in interface FeatureStore<SimpleFeatureType,SimpleFeature>
filter
- an OpenGIS filterIOException
- if an error occurs modifying the data sourceCopyright © 1996–2019 Geotools. All rights reserved.