Package org.apache.sis.storage
Interface WritableFeatureSet
- All Superinterfaces:
- DataSet,- FeatureSet,- Resource
A 
FeatureSet with writing capabilities. WritableFeatureSet inherits the reading capabilities from
 its parent and adds the capabilities to add, remove
 or replace feature instances.- Since:
- 1.0
Defined in the sis-storage module
- 
Method SummaryModifier and TypeMethodDescriptionvoidadd(Iterator<? extends AbstractFeature> features) Inserts new feature instances in thisFeatureSet.booleanremoveIf(Predicate<? super AbstractFeature> filter) Removes all feature instances from thisFeatureSetwhich matches the given predicate.voidreplaceIf(Predicate<? super AbstractFeature> filter, UnaryOperator<AbstractFeature> updater) Updates all feature instances from thisFeatureSetwhich match the given predicate.voidupdateType(DefaultFeatureType newType) Declares or redefines the type of all feature instances in this feature set.Methods inherited from interface DataSetgetEnvelopeMethods inherited from interface FeatureSetfeatures, getType, subsetMethods inherited from interface ResourceaddListener, getIdentifier, getMetadata, removeListener
- 
Method Details- 
updateTypeDeclares or redefines the type of all feature instances in this feature set. In the case of a newly created feature set, this method can be used for defining the type of features to be stored (this is not a required step however). In the case of a feature set which already contains feature instances, this operation may take an undefined amount of time to execute since all features in the set may need to be transformed.Feature sets may restrict the kind of changes that are allowed. An IllegalFeatureTypeExceptionwill be thrown if the given type contains incompatible property changes.- Parameters:
- newType- new feature type definition (not- null).
- Throws:
- IllegalFeatureTypeException- if the given type is not compatible with the types supported by the store.
- DataStoreException- if another error occurred while changing the feature type.
 
- 
addInserts new feature instances in thisFeatureSet. Any feature already present in thisFeatureSetwill remain unmodified. If a feature property is used as unique identifier, then:- If a given feature assigns to that property a value already in use, an exception will be thrown.
- If given features do not assign value to that property, identifiers should be generated by the data store.
 DataStorespecific.API note: this method expects anIteratorrather than aStreamfor easing inter-operability with various API. Implementing a customIteratorrequires less effort than implementing aStream. On the other side if the user has aStream, obtaining anIteratorcan be done by a call toBaseStream.iterator().- Parameters:
- features- feature instances to insert or copy in this- FeatureSet.
- Throws:
- IllegalFeatureTypeException- if a feature given by the iterator is not of the type expected by this- FeatureSet.
- DataStoreException- if another error occurred while storing new features.
 
- 
removeIfRemoves all feature instances from thisFeatureSetwhich matches the given predicate.Possible API change: Thebooleanreturn type may be removed in a future version. It currently exists for compatibility with theCollection.removeIf(Predicate)method if an implementation chooses to implementsWritableFeatureSetandCollectionin same time. But this is not recommended, and the current method signature is a blocker for deferred method execution. Telling if there is any feature to remove requires immediate execution of the filter, while an implementation may want to wait in case the filtering can be combined with other operations such asadd(…)orreplaceIf(…). See SIS-560 on issue tracker.- Parameters:
- filter- a predicate which returns- truefor feature instances to be removed.
- Returns:
- trueif any elements were removed.
- Throws:
- DataStoreException- if an error occurred while removing features.
 
- 
replaceIfvoid replaceIf(Predicate<? super AbstractFeature> filter, UnaryOperator<AbstractFeature> updater) throws DataStoreException Updates all feature instances from thisFeatureSetwhich match the given predicate. For eachFeatureinstance matching the givenPredicate, theUnaryOperator.apply(Feature)method will be invoked.UnaryOperators are free to modify the givenFeaturein-place or to return a different feature instance. Two behaviors are possible:- If the operator returns a non-null Feature, then the modified feature is stored in replacement of the previous feature (not necessarily at the same location).
- If the operator returns null, then the feature will be removed from theFeatureSet.
 - Parameters:
- filter- a predicate which returns- truefor feature instances to be updated.
- updater- operation called for each matching- Featureinstance.
- Throws:
- IllegalFeatureTypeException- if a feature given by the operator is not of the type expected by this- FeatureSet.
- DataStoreException- if another error occurred while replacing features.
 
- If the operator returns a non-null 
 
-