Class MemoryDataStore
- Object
-
- ContentDataStore
-
- MemoryDataStore
-
- All Implemented Interfaces:
DataAccess<SimpleFeatureType,SimpleFeature>
,DataStore
public class MemoryDataStore extends ContentDataStore
This is an example implementation of a DataStore used for testing.It serves as an example implementation of:
- FeatureListenerManager use: allows handling of FeatureEvents
This class will also illustrate the use of In-Process locking when the time comes.
- Author:
- jgarnett
-
-
Field Summary
-
Fields inherited from class ContentDataStore
dataStoreFactory, entries, featureFactory, filterFactory, geometryFactory, JOINED_FEATURE_TYPE, lockingManager, LOGGER, namespaceURI, typeFactory, WRITER_ADD, WRITER_COMMIT, WRITER_UPDATE
-
-
Constructor Summary
Constructors Constructor Description MemoryDataStore()
MemoryDataStore(FeatureReader<SimpleFeatureType,SimpleFeature> reader)
MemoryDataStore(SimpleFeature... array)
MemoryDataStore(SimpleFeatureType featureType)
Construct an MemoryDataStore around an empty collection of the provided SimpleFeatureTypeMemoryDataStore(SimpleFeatureCollection collection)
MemoryDataStore(SimpleFeatureIterator reader)
MemoryDataStore(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addFeature(SimpleFeature feature)
Adds a single Feature to the correct typeName entry.void
addFeatures(Collection<?> collection)
Configures MemoryDataStore with Collection.void
addFeatures(FeatureReader<SimpleFeatureType,SimpleFeature> reader)
Configures MemoryDataStore with FeatureReader.void
addFeatures(SimpleFeature... features)
Configures MemoryDataStore with feature array.void
addFeatures(SimpleFeatureIterator reader)
Configures MemoryDataStore with FeatureReader.void
addFeatures(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
protected MemoryState
createContentState(ContentEntry entry)
Use MemoryState to manage internal storage.protected ContentFeatureSource
createFeatureSource(ContentEntry entry)
Instantiates new feature source for the entry.protected ContentFeatureSource
createFeatureSource(ContentEntry entry, Query query)
void
createSchema(SimpleFeatureType featureType)
Adds support for a new featureType to MemoryDataStore.protected List<Name>
createTypeNames()
List of available types provided by this DataStore.protected MemoryEntry
entry(String typeName)
Access MemoryState for typeName.protected MemoryEntry
entry(SimpleFeatureType schema)
Access to entry to store content of the provided schema, will create new entry if needed.void
removeSchema(String typeName)
Used to permanently remove a schema from the underlying storagevoid
removeSchema(Name typeName)
Used to permanently remove a schema from the underlying storage-
Methods inherited from class ContentDataStore
dispose, ensureEntry, ensureFeatureStore, entry, getDataStoreFactory, getEntry, getFeatureFactory, getFeatureReader, getFeatureSource, getFeatureSource, getFeatureSource, getFeatureSource, getFeatureTypeFactory, getFeatureWriter, getFeatureWriter, getFeatureWriterAppend, getFilterFactory, getGeometryFactory, getInfo, getLockingManager, getLogger, getNames, getNamespaceURI, getSchema, getSchema, getTypeNames, name, removeEntry, setDataStoreFactory, setFeatureFactory, setFeatureTypeFactory, setFilterFactory, setGeometryFactory, setNamespaceURI, updateSchema, updateSchema
-
-
-
-
Constructor Detail
-
MemoryDataStore
public MemoryDataStore()
-
MemoryDataStore
public MemoryDataStore(SimpleFeatureType featureType)
Construct an MemoryDataStore around an empty collection of the provided SimpleFeatureType- Parameters:
featureType
- The initial feature type for the memory data store, an empty feature collection of this type will be made available
-
MemoryDataStore
public MemoryDataStore(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
-
MemoryDataStore
public MemoryDataStore(SimpleFeatureCollection collection)
-
MemoryDataStore
public MemoryDataStore(SimpleFeature... array)
-
MemoryDataStore
public MemoryDataStore(FeatureReader<SimpleFeatureType,SimpleFeature> reader) throws IOException
- Throws:
IOException
-
MemoryDataStore
public MemoryDataStore(SimpleFeatureIterator reader) throws IOException
- Throws:
IOException
-
-
Method Detail
-
createContentState
protected MemoryState createContentState(ContentEntry entry)
Use MemoryState to manage internal storage.- Overrides:
createContentState
in classContentDataStore
- Parameters:
entry
- The entry.- Returns:
- A new instance of
ContentState
for the entry.
-
addFeatures
public void addFeatures(FeatureReader<SimpleFeatureType,SimpleFeature> reader) throws IOException
Configures MemoryDataStore with FeatureReader.- Parameters:
reader
- New contents to add- Throws:
IOException
- If problems are encountered while addingDataSourceException
- See IOException
-
addFeatures
public void addFeatures(SimpleFeatureIterator reader) throws IOException
Configures MemoryDataStore with FeatureReader.- Parameters:
reader
- New contents to add- Throws:
IOException
- If problems are encountered while addingDataSourceException
- See IOException
-
addFeatures
public void addFeatures(Collection<?> collection)
Configures MemoryDataStore with Collection.You may use this to create a MemoryDataStore from a FeatureCollection.
- Parameters:
collection
- Collection of features to add- Throws:
IllegalArgumentException
- If provided collection is empty
-
addFeatures
public void addFeatures(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)
-
addFeatures
public void addFeatures(SimpleFeature... features)
Configures MemoryDataStore with feature array.- Parameters:
features
- Array of features to add- Throws:
IllegalArgumentException
- If provided feature array is empty
-
addFeature
public void addFeature(SimpleFeature feature)
Adds a single Feature to the correct typeName entry.This is an internal operation used for setting up MemoryDataStore - please use FeatureWriter for general use.
This method is willing to create new FeatureTypes for MemoryDataStore.
- Parameters:
feature
- Individual feature to add
-
entry
protected MemoryEntry entry(String typeName) throws IOException
Access MemoryState for typeName.Technically this is accessing the MemoryState for
Transaction.AUTO_COMMIT
, which is the definitive storage for the feature content.- Returns:
- MemoryState storing feature (by FeatureID)
- Throws:
IOException
- If typeName cannot be found
-
entry
protected MemoryEntry entry(SimpleFeatureType schema) throws IOException
Access to entry to store content of the provided schema, will create new entry if needed.- Returns:
- MemoryState used for content storage
- Throws:
IOException
- If new entry could not be created due to typeName conflict
-
createTypeNames
protected List<Name> createTypeNames()
List of available types provided by this DataStore.- Specified by:
createTypeNames
in classContentDataStore
- Returns:
- List of type names
- See Also:
org.geotools.data.ContentDataStore#getFeatureTypes()
-
createFeatureSource
protected ContentFeatureSource createFeatureSource(ContentEntry entry)
Description copied from class:ContentDataStore
Instantiates new feature source for the entry.Subclasses should override this method to return a specific subclass of
ContentFeatureSource
.- Specified by:
createFeatureSource
in classContentDataStore
- Parameters:
entry
- The entry.- Returns:
- An new instance of
ContentFeatureSource
for the entry.
-
createFeatureSource
protected ContentFeatureSource createFeatureSource(ContentEntry entry, Query query)
-
createSchema
public void createSchema(SimpleFeatureType featureType) throws IOException
Adds support for a new featureType to MemoryDataStore.FeatureTypes are stored by typeName, an IOException will be thrown if the requested typeName is already in use.
- Specified by:
createSchema
in interfaceDataAccess<SimpleFeatureType,SimpleFeature>
- Overrides:
createSchema
in classContentDataStore
- Parameters:
featureType
- SimpleFeatureType to be added- Throws:
IOException
- If featureType already exists- See Also:
DataStore#createSchema(org.geotools.feature.SimpleFeatureType)
-
removeSchema
public void removeSchema(String typeName) throws IOException
Description copied from interface:DataStore
Used to permanently remove a schema from the underlying storageThis functionality is similar to an "drop table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.
- Specified by:
removeSchema
in interfaceDataStore
- Overrides:
removeSchema
in classContentDataStore
- Throws:
IOException
- if the operation failed- See Also:
DataStore.removeSchema(String)
-
removeSchema
public void removeSchema(Name typeName) throws IOException
Description copied from interface:DataAccess
Used to permanently remove a schema from the underlying storageThis functionality is similar to an "drop table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.
- Specified by:
removeSchema
in interfaceDataAccess<SimpleFeatureType,SimpleFeature>
- Overrides:
removeSchema
in classContentDataStore
- Throws:
IOException
- if the operation failed- See Also:
DataAccess.removeSchema(Name)
-
-