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 voidaddFeature(SimpleFeature feature)Adds a single Feature to the correct typeName entry.voidaddFeatures(Collection<?> collection)Configures MemoryDataStore with Collection.voidaddFeatures(FeatureReader<SimpleFeatureType,SimpleFeature> reader)Configures MemoryDataStore with FeatureReader.voidaddFeatures(SimpleFeature... features)Configures MemoryDataStore with feature array.voidaddFeatures(SimpleFeatureIterator reader)Configures MemoryDataStore with FeatureReader.voidaddFeatures(FeatureCollection<SimpleFeatureType,SimpleFeature> collection)protected MemoryStatecreateContentState(ContentEntry entry)Use MemoryState to manage internal storage.protected ContentFeatureSourcecreateFeatureSource(ContentEntry entry)Instantiates new feature source for the entry.protected ContentFeatureSourcecreateFeatureSource(ContentEntry entry, Query query)voidcreateSchema(SimpleFeatureType featureType)Adds support for a new featureType to MemoryDataStore.protected List<Name>createTypeNames()List of available types provided by this DataStore.protected MemoryEntryentry(String typeName)Access MemoryState for typeName.protected MemoryEntryentry(SimpleFeatureType schema)Access to entry to store content of the provided schema, will create new entry if needed.voidremoveSchema(String typeName)Used to permanently remove a schema from the underlying storagevoidremoveSchema(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:
createContentStatein classContentDataStore- Parameters:
entry- The entry.- Returns:
- A new instance of
ContentStatefor 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:
createTypeNamesin classContentDataStore- Returns:
- List of type names
- See Also:
org.geotools.data.ContentDataStore#getFeatureTypes()
-
createFeatureSource
protected ContentFeatureSource createFeatureSource(ContentEntry entry)
Description copied from class:ContentDataStoreInstantiates new feature source for the entry.Subclasses should override this method to return a specific subclass of
ContentFeatureSource.- Specified by:
createFeatureSourcein classContentDataStore- Parameters:
entry- The entry.- Returns:
- An new instance of
ContentFeatureSourcefor 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:
createSchemain interfaceDataAccess<SimpleFeatureType,SimpleFeature>- Overrides:
createSchemain 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:DataStoreUsed 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:
removeSchemain interfaceDataStore- Overrides:
removeSchemain classContentDataStore- Throws:
IOException- if the operation failed- See Also:
DataStore.removeSchema(String)
-
removeSchema
public void removeSchema(Name typeName) throws IOException
Description copied from interface:DataAccessUsed 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:
removeSchemain interfaceDataAccess<SimpleFeatureType,SimpleFeature>- Overrides:
removeSchemain classContentDataStore- Throws:
IOException- if the operation failed- See Also:
DataAccess.removeSchema(Name)
-
-