Package com.vividsolutions.jump.feature
Class FeatureCollectionWrapper
- java.lang.Object
-
- com.vividsolutions.jump.feature.FeatureCollectionWrapper
-
- All Implemented Interfaces:
FeatureCollection,Iterable<Feature>
- Direct Known Subclasses:
CachingFeatureCollection,IndexedFeatureCollection,ObservableFeatureCollection,OneItemFeatureCollection
public abstract class FeatureCollectionWrapper extends Object implements FeatureCollection
Delegates to another instance of FeatureCollection. A useful means of overriding the behaviour of a FeatureCollection dynamically, at run-time (i.e. without subclassing).
-
-
Constructor Summary
Constructors Constructor Description FeatureCollectionWrapper(FeatureCollection fc)Constructs a FeatureCollectionWrapper that delegates to the given FeatureCollection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(Feature feature)Adds a feature to this collection.voidaddAll(Collection<Feature> features)Adds multiple features to this collection.voidcheckNotWrappingSameClass()Throws an AssertionFailedException if this FeatureCollectionWrapper wraps (directly or indirectly) another FeatureCollectionWrapper having the same class (or descendant class thereof).voidclear()Removes all features from this collection.org.locationtech.jts.geom.EnvelopegetEnvelope()Returns the bounds of this collection.protected FeatureCollectiongetFeatureCollection()List<Feature>getFeatures()Returns an unmodifiable List of the features in this collectionFeatureSchemagetFeatureSchema()Returns information about this FeatureCollectionFeatureCollectiongetUltimateWrappee()Returns the non-wrapper FeatureCollection wrapped by this wrapper and possibly by other wrappers in-between.FeatureCollectiongetWrappee()Returns the FeatureCollection that this wrapper delegates to (possibly another FeatureCollectionWrapper).FeatureCollectiongetWrappee(Class c)Return the wrapper matching the given class or null, if there is none.booleanhasWrapper(Class c)Returns whether this FeatureCollectionWrapper (or a FeatureCollectionWrapper that it wraps, directly or indirectly) is an instance of the given class (or one of its descendants).booleanisEmpty()Returns whether this collection has no features.Iterator<Feature>iterator()Returns an Iterator over the featuresList<Feature>query(org.locationtech.jts.geom.Envelope envelope)A quick search for features, using an envelope comparison.voidremove(Feature feature)Removes a feature from this collection.Collection<Feature>remove(org.locationtech.jts.geom.Envelope env)Removes the features which intersect the given envelopevoidremoveAll(Collection<Feature> features)Removes multiple features from this collection.protected voidsetFeatureCollection(FeatureCollection featureCollection)intsize()Returns the number of features in this collection.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Constructor Detail
-
FeatureCollectionWrapper
public FeatureCollectionWrapper(FeatureCollection fc)
Constructs a FeatureCollectionWrapper that delegates to the given FeatureCollection.
-
-
Method Detail
-
getUltimateWrappee
public FeatureCollection getUltimateWrappee()
Returns the non-wrapper FeatureCollection wrapped by this wrapper and possibly by other wrappers in-between. Intended to get at the "real" FeatureCollection underneath several layers of FeatureCollectionWrappers.- See Also:
getWrappee()
-
checkNotWrappingSameClass
public void checkNotWrappingSameClass()
Throws an AssertionFailedException if this FeatureCollectionWrapper wraps (directly or indirectly) another FeatureCollectionWrapper having the same class (or descendant class thereof). A consistency check that is useful for some FeatureCollectionWrapper implementations.
-
remove
public Collection<Feature> remove(org.locationtech.jts.geom.Envelope env)
Description copied from interface:FeatureCollectionRemoves the features which intersect the given envelope- Specified by:
removein interfaceFeatureCollection- Returns:
- the removed features
-
hasWrapper
public boolean hasWrapper(Class c)
Returns whether this FeatureCollectionWrapper (or a FeatureCollectionWrapper that it wraps, directly or indirectly) is an instance of the given class (or one of its descendants).
-
getWrappee
public FeatureCollection getWrappee(Class c)
Return the wrapper matching the given class or null, if there is none.- Parameters:
c- the Class of the wrapper we are looking for- Returns:
- a wrapper of Class c
-
getWrappee
public FeatureCollection getWrappee()
Returns the FeatureCollection that this wrapper delegates to (possibly another FeatureCollectionWrapper).- See Also:
getUltimateWrappee()
-
getFeatureSchema
public FeatureSchema getFeatureSchema()
Description copied from interface:FeatureCollectionReturns information about this FeatureCollection- Specified by:
getFeatureSchemain interfaceFeatureCollection- Returns:
- the types of the attributes of the features in this collection
-
getEnvelope
public org.locationtech.jts.geom.Envelope getEnvelope()
Description copied from interface:FeatureCollectionReturns the bounds of this collection.- Specified by:
getEnvelopein interfaceFeatureCollection- Returns:
- the smallest Envelope enclosing all the Features in this collection
-
size
public int size()
Description copied from interface:FeatureCollectionReturns the number of features in this collection.- Specified by:
sizein interfaceFeatureCollection- Returns:
- the number of features in this collection
-
isEmpty
public boolean isEmpty()
Description copied from interface:FeatureCollectionReturns whether this collection has no features.- Specified by:
isEmptyin interfaceFeatureCollection- Returns:
- whether or not the size of this collection is 0
-
getFeatures
public List<Feature> getFeatures()
Description copied from interface:FeatureCollectionReturns an unmodifiable List of the features in this collection- Specified by:
getFeaturesin interfaceFeatureCollection- Returns:
- a read-only view of all the features
-
iterator
public Iterator<Feature> iterator()
Description copied from interface:FeatureCollectionReturns an Iterator over the features- Specified by:
iteratorin interfaceFeatureCollection- Specified by:
iteratorin interfaceIterable<Feature>- Returns:
- an Iterator over the features
-
query
public List<Feature> query(org.locationtech.jts.geom.Envelope envelope)
Description copied from interface:FeatureCollectionA quick search for features, using an envelope comparison.- Specified by:
queryin interfaceFeatureCollection- Parameters:
envelope- the envelope to query against- Returns:
- features whose envelopes intersect the given envelope
-
add
public void add(Feature feature)
Description copied from interface:FeatureCollectionAdds a feature to this collection.- Specified by:
addin interfaceFeatureCollection- Parameters:
feature- a Feature to add to the end of this collection
-
remove
public void remove(Feature feature)
Description copied from interface:FeatureCollectionRemoves a feature from this collection.- Specified by:
removein interfaceFeatureCollection- Parameters:
feature- a Feature to remove from this collection
-
addAll
public void addAll(Collection<Feature> features)
Description copied from interface:FeatureCollectionAdds multiple features to this collection. To be preferred over #add for adding multiple features, because in some systems (like the JUMP Workbench) fewer events will be fired.- Specified by:
addAllin interfaceFeatureCollection
-
removeAll
public void removeAll(Collection<Feature> features)
Description copied from interface:FeatureCollectionRemoves multiple features from this collection. To be preferred over #remove for removing multiple features, because in some systems (like the JUMP Workbench) fewer events will be fired.- Specified by:
removeAllin interfaceFeatureCollection
-
clear
public void clear()
Description copied from interface:FeatureCollectionRemoves all features from this collection.- Specified by:
clearin interfaceFeatureCollection
-
getFeatureCollection
protected FeatureCollection getFeatureCollection()
-
setFeatureCollection
protected void setFeatureCollection(FeatureCollection featureCollection)
-
-