- 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
-
Method Summary
Modifier and TypeMethodDescriptionvoidadd(Iterator<? extends AbstractFeature> features) Inserts new feature instances in thisFeatureSet.voidremoveIf(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 DataSet
getEnvelopeMethods inherited from interface FeatureSet
features, getType, subsetMethods inherited from interface Resource
addListener, getIdentifier, getMetadata, removeListener
-
Method Details
-
updateType
Declares 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 (notnull).- 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.
-
add
Inserts 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 thisFeatureSet.- Throws:
IllegalFeatureTypeException- if a feature given by the iterator is not of the type expected by thisFeatureSet.DataStoreException- if another error occurred while storing new features.
-
removeIf
Removes all feature instances from thisFeatureSetwhich matches the given predicate.- Parameters:
filter- a predicate which returnstruefor feature instances to be removed.- Throws:
DataStoreException- if an error occurred while removing features.
-
replaceIf
void 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 returnstruefor feature instances to be updated.updater- operation called for each matchingFeatureinstance.- Throws:
IllegalFeatureTypeException- if a feature given by the operator is not of the type expected by thisFeatureSet.DataStoreException- if another error occurred while replacing features.
- If the operator returns a non-null
-