Package org.geotools.data.memory
Class MemoryFeatureSource
- Object
-
- ContentFeatureSource
-
- MemoryFeatureSource
-
- All Implemented Interfaces:
FeatureSource<SimpleFeatureType,SimpleFeature>
,SimpleFeatureSource
public class MemoryFeatureSource extends ContentFeatureSource
Read access to feature content held in memory.- Author:
- Jody Garnett (Boundless)
-
-
Field Summary
-
Fields inherited from class ContentFeatureSource
entry, hints, lock, query, queryCapabilities, schema, transaction
-
-
Constructor Summary
Constructors Constructor Description MemoryFeatureSource(ContentEntry entry)
MemoryFeatureSource(ContentEntry entry, Query query)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected SimpleFeatureType
buildFeatureType()
Creates the feature type or schema for the feature source.protected ReferencedEnvelope
getBoundsInternal(Query query)
Calculates the bounds of a specified query.protected int
getCountInternal(Query query)
Calculates the number of features of a specified query.MemoryDataStore
getDataStore()
Access parent MemoryDataStore.MemoryEntry
getEntry()
The entry for the feature source.protected FeatureReader<SimpleFeatureType,SimpleFeature>
getReaderInternal(Query query)
Subclass method for returning a native reader from the datastore.MemoryState
getState()
The current state for the feature source.protected boolean
handleVisitor(Query query, FeatureVisitor visitor)
Subclass method which allows subclasses to natively handle a visitor.-
Methods inherited from class ContentFeatureSource
accepts, addFeatureListener, addHints, buildQueryCapabilities, canEvent, canFilter, canFilter, canLimit, canLimit, canLock, canOffset, canOffset, canReproject, canRetype, canRetype, canSort, canSort, canTransact, doLockInternal, doUnlockInternal, getAbsoluteSchema, getBounds, getBounds, getCount, getFeatures, getFeatures, getFeatures, getInfo, getName, getQueryCapabilities, getReader, getReader, getReader, getSchema, getSupportedHints, getTransaction, getView, getView, isView, joinQuery, lockFeatures, lockFeatures, lockFeatures, processLock, removeFeatureListener, resolvePropertyNames, resolvePropertyNames, setFeatureLock, setTransaction, unLockFeatures, unLockFeatures, unLockFeatures
-
-
-
-
Constructor Detail
-
MemoryFeatureSource
public MemoryFeatureSource(ContentEntry entry)
-
MemoryFeatureSource
public MemoryFeatureSource(ContentEntry entry, Query query)
-
-
Method Detail
-
getDataStore
public MemoryDataStore getDataStore()
Access parent MemoryDataStore.- Specified by:
getDataStore
in interfaceFeatureSource<SimpleFeatureType,SimpleFeature>
- Overrides:
getDataStore
in classContentFeatureSource
- Returns:
- the data source providing this
FeatureSource
-
getState
public MemoryState getState()
Description copied from class:ContentFeatureSource
The current state for the feature source.This value is derived from current transaction of the feature source.
- Overrides:
getState
in classContentFeatureSource
-
getEntry
public MemoryEntry getEntry()
The entry for the feature source.- Overrides:
getEntry
in classContentFeatureSource
-
getBoundsInternal
protected ReferencedEnvelope getBoundsInternal(Query query) throws IOException
Description copied from class:ContentFeatureSource
Calculates the bounds of a specified query. Subclasses must implement this method. If the computation is not fast, subclasses can returnnull
.- Specified by:
getBoundsInternal
in classContentFeatureSource
- Throws:
IOException
-
getCountInternal
protected int getCountInternal(Query query) throws IOException
Description copied from class:ContentFeatureSource
Calculates the number of features of a specified query. Subclasses must implement this method. If the computation is not fast, it's possible to return -1.- Specified by:
getCountInternal
in classContentFeatureSource
- Throws:
IOException
-
getReaderInternal
protected FeatureReader<SimpleFeatureType,SimpleFeature> getReaderInternal(Query query) throws IOException
Description copied from class:ContentFeatureSource
Subclass method for returning a native reader from the datastore.It is important to note that if the native reader intends to handle any of the following natively:
- reprojection
- filtering
- max feature limiting
- sorting
- locking
- transactions
true
:ContentFeatureSource.canReproject()
- handlesQuery.getCoordinateSystemReproject()
internally. Example would be PostGIS using Proj to handle reproejction internallyContentFeatureSource.canFilter(Query)
- handlesinternally.
- {@link #canLimit(Query)} - handles {@link Query#getMaxFeatures()} and {@link Query#getStartIndex()} internally.
- {@link #canSort(Query)} - handles {@link Query#getSortBy()} natively.
- {@link #canRetype(Query)} - handles {@link Query#getProperties()} natively. Example would be only parsing the properties the user asks for from an XML file
- {@link #canLock()} - handles read-locks natively
- {@link #canTransact()} - handles transactions natively
- Specified by:
getReaderInternal
in classContentFeatureSource
- Throws:
IOException
-
buildFeatureType
protected SimpleFeatureType buildFeatureType()
Description copied from class:ContentFeatureSource
Creates the feature type or schema for the feature source.Implementations should use
SimpleFeatureTypeBuilder
to build the feature type. Also, the builder should be injected with the feature factory which has been set on the DataStore (seeContentDataStore.getFeatureFactory()
. Example:SimpleFeatureTypeBuilder b = new SimpleFeatureTypeBuilder(); b.setFeatureTypeFactory( getDataStore().getFeatureTypeFactory() ); //build the feature type ...
- Specified by:
buildFeatureType
in classContentFeatureSource
-
handleVisitor
protected boolean handleVisitor(Query query, FeatureVisitor visitor) throws IOException
Description copied from class:ContentFeatureSource
Subclass method which allows subclasses to natively handle a visitor.Subclasses would override this method and return true in cases where the specific visitor could be handled without iterating over the entire result set of query. An example would be handling visitors that calculate aggregate values.
- Overrides:
handleVisitor
in classContentFeatureSource
- Parameters:
query
- The query being made.visitor
- The visitor to- Returns:
- true if the visitor can be handled natively, otherwise false.
- Throws:
IOException
-
-