com.vividsolutions.jump.workbench.model.cache
Class CachingFeatureCollection

java.lang.Object
  extended by com.vividsolutions.jump.feature.FeatureCollectionWrapper
      extended by com.vividsolutions.jump.workbench.model.cache.CachingFeatureCollection
All Implemented Interfaces:
FeatureCollection

public class CachingFeatureCollection
extends FeatureCollectionWrapper

Caches features to prevent unnecessary queries. Useful for wrapping database-backed FeatureCollections. All calls are delegated to the cache, except for calls to query(envelope).iterator() where (1) the envelope is not within the cache envelope, and (2) the call is made in a non-GUI thread.


Constructor Summary
CachingFeatureCollection(FeatureCollection featureCollection)
           
 
Method Summary
 void emptyCache()
           
 com.vividsolutions.jts.geom.Envelope getEnvelope()
          Returns the bounds of this collection.
 FeatureSchema getFeatureSchema()
          Returns information about this FeatureCollection
 java.util.List query(com.vividsolutions.jts.geom.Envelope envelope)
          A quick search for features, using an envelope comparison.
 CachingFeatureCollection setCachingByEnvelope(boolean cachingByEnvelope)
          This setting is ignored if the call to query(envelope).iterator() is made on the GUI thread, because long queries would make the GUI unresponsive.
 
Methods inherited from class com.vividsolutions.jump.feature.FeatureCollectionWrapper
add, addAll, checkNotWrappingSameClass, clear, getFeatures, getUltimateWrappee, getWrappee, hasWrapper, isEmpty, iterator, remove, remove, removeAll, size
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CachingFeatureCollection

public CachingFeatureCollection(FeatureCollection featureCollection)
Method Detail

getEnvelope

public com.vividsolutions.jts.geom.Envelope getEnvelope()
Description copied from interface: FeatureCollection
Returns the bounds of this collection.

Specified by:
getEnvelope in interface FeatureCollection
Overrides:
getEnvelope in class FeatureCollectionWrapper
Returns:
the smallest Envelope enclosing all the Features in this collection
See Also:
FeatureCollectionWrapper.getEnvelope()

getFeatureSchema

public FeatureSchema getFeatureSchema()
Description copied from interface: FeatureCollection
Returns information about this FeatureCollection

Specified by:
getFeatureSchema in interface FeatureCollection
Overrides:
getFeatureSchema in class FeatureCollectionWrapper
Returns:
the types of the attributes of the features in this collection
See Also:
FeatureCollectionWrapper.getFeatureSchema()

query

public java.util.List query(com.vividsolutions.jts.geom.Envelope envelope)
Description copied from interface: FeatureCollection
A quick search for features, using an envelope comparison.

Specified by:
query in interface FeatureCollection
Overrides:
query in class FeatureCollectionWrapper
Parameters:
envelope - the envelope to query against
Returns:
features whose envelopes intersect the given envelope

setCachingByEnvelope

public CachingFeatureCollection setCachingByEnvelope(boolean cachingByEnvelope)
This setting is ignored if the call to query(envelope).iterator() is made on the GUI thread, because long queries would make the GUI unresponsive.

Parameters:
cachingByEnvelope - whether query(envelope).iterator() delegates to the cache if envelope is within the cache envelope

emptyCache

public void emptyCache()