Class ContentDataStore
- All Implemented Interfaces:
DataAccess<SimpleFeatureType,,SimpleFeature> DataStore
- Direct Known Subclasses:
CSVDataStore,GeoJSONDataStore,GraticuleDataStore,JDBCDataStore,MBTilesDataStore,MemoryDataStore,MongoDataStore,OGRDataStore,PropertyDataStore,ShapefileDataStore,STACDataStore,VectorMosaicStore,VectorTilesDataStore,VPFFileStore,VPFLibrary,WFSDataStore
A datastore contains a set of entries (ContentEntry). Each entry corresponds to a "real world dataset".
For instance, a shapefile datastore would contain a single entry which would represent the shapefile on disk. A
postgis datastore could contain many entries, one for each table in the database.
Each entry is identified by a name (Name). The name can be qualified with a namespace uri, or unqualified
(in which the namespace uri is null). An example of a datastore that might use qualified names is WFS, where in each
entry corresponds to a WFS "Feature Type", which have namespace qualified name. Other datastores (such as databases)
use unqualified names.
When entry names of a datastore are unqualified, a default namespace uri can be set "globally" on the datastore
itself, see setNamespaceURI(String). When this value is set, unqualified entry names are implicitly
qualified with the global namespace uri.
Subclasses
At a minimum subclasses must implement the following methods:
The following methods may also be overriden: The following methods may be overriden but only to narrow the return type to a specific subclass ofContentFeatureSource.
- Author:
- Jody Garnett, Refractions Research Inc., Justin Deoliveira, The Open Planning Project, Niels Charlier
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected DataStoreFactorySpifactory used to create the datastoreprotected final Map<Name,ContentEntry> name, entry mapprotected FeatureFactoryFactory used to create featuresprotected FilterFactoryFactory used to create filtersprotected GeometryFactoryFactory used to create geometriesstatic final StringWhen joining feature types, the UserData of the joined attribute descriptors will contain their full feature type under this keyprotected LockingManagerlocking managerprotected final Loggerloggerprotected Stringnamespace uri of the datastore itself, or default namespaceprotected FeatureTypeFactoryFactory used to create feature typesprotected static final intFlag writer for adding new contentprotected static final intFlag writer for commit (AUTO_COMMIT with no events)protected static final intFlag writer for updating content in place -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ContentStatecreateContentState(ContentEntry entry) Instantiates a new content state for the entry.protected abstract ContentFeatureSourcecreateFeatureSource(ContentEntry entry) Instantiates new feature source for the entry.voidcreateSchema(SimpleFeatureType featureType) Creates a new schema in the datastore.Creates a set of qualified names corresponding to the types that the datastore provides.voiddispose()Disposes of this data store and releases any resource that it is using.protected final ContentEntryensureEntry(Name name) Helper method to look up an entry in the datastore which throws anIOExceptionin the event that the entry does not exist.protected final ContentFeatureStoreensureFeatureStore(String typeName, Transaction tx) Helper method which gets a feature source ensuring that it is a feature store as well.protected final ContentEntryHelper method to look up an entry in the datastore.Returns the factory used to create the data store.Returns the entry for a specified name, ornullif no such entry exists.The factory used to create features.getFeatureReader(Query query, Transaction tx) Returns a feature reader for the specified query and transaction.getFeatureSource(String typeName) Returns the feature source matching the specified name.getFeatureSource(String typeName, Transaction tx) Returns the feature source matching the specified name and explicitly specifies a transaction.getFeatureSource(Name typeName) Delegates togetFeatureSource(Name, Transaction)getFeatureSource(Name typeName, Transaction tx) Returns the feature source matching the specified name and explicitly specifies a transaction.The factory used to create feature types.getFeatureWriter(String typeName, Transaction tx) Returns a feature writer for the specified type name and transaction.getFeatureWriter(String typeName, Filter filter, Transaction tx) Returns a feature writer for the specified query and transaction.getFeatureWriterAppend(String typeName, Transaction tx) Returns an appending feature writer for the specified type name and transaction.The factory used to create filters.The factory used to create geometries.getInfo()Information about this service.final LockingManagerRetrieve a per featureID based locking service from thisDataStore.The logger for the datastore.getNames()Returns the same list of names thangetTypeNames()meaning the returned Names have no namespace set.The namespace uri of the datastore.final SimpleFeatureTypeReturns the feature type or schema matching the specified name.Delegates togetSchema(String)withname.getLocalPart()final String[]Returns the names of all entries or types provided by the datastore.protected final NameHelper method to wrap a non-qualified name.protected final voidremoveEntry(Name name) Helper method to remove an entry from the cached entry map.voidremoveSchema(String typeName) Used to permanently remove a schema from the underlying storagevoidremoveSchema(Name typeName) Used to permanently remove a schema from the underlying storagevoidsetDataStoreFactory(DataStoreFactorySpi dataStoreFactory) Sets the data store factory used to create the datastore.voidsetFeatureFactory(FeatureFactory featureFactory) Sets the factory used to create features.voidsetFeatureTypeFactory(FeatureTypeFactory typeFactory) Sets the factory used to create feature types.voidsetFilterFactory(FilterFactory filterFactory) Sets the factory used to create filters.voidsetGeometryFactory(GeometryFactory geometryFactory) Sets the factory used to create geometries.voidsetNamespaceURI(String namespaceURI) Sets the namespace uri of the datastore.final voidupdateSchema(String typeName, SimpleFeatureType featureType) Applies a new schema to the given feature type.voidupdateSchema(Name typeName, SimpleFeatureType featureType) Delegates toupdateSchema(String, SimpleFeatureType)withname.getLocalPart()
-
Field Details
-
JOINED_FEATURE_TYPE
When joining feature types, the UserData of the joined attribute descriptors will contain their full feature type under this key- See Also:
-
WRITER_ADD
protected static final int WRITER_ADDFlag writer for adding new content- See Also:
-
WRITER_UPDATE
protected static final int WRITER_UPDATEFlag writer for updating content in place- See Also:
-
WRITER_COMMIT
protected static final int WRITER_COMMITFlag writer for commit (AUTO_COMMIT with no events)- See Also:
-
entries
name, entry map -
LOGGER
logger -
typeFactory
Factory used to create feature types -
featureFactory
Factory used to create features -
filterFactory
Factory used to create filters -
geometryFactory
Factory used to create geometries -
namespaceURI
namespace uri of the datastore itself, or default namespace -
lockingManager
locking manager -
dataStoreFactory
factory used to create the datastore
-
-
Constructor Details
-
ContentDataStore
public ContentDataStore()
-
-
Method Details
-
getFeatureTypeFactory
The factory used to create feature types. -
setFeatureTypeFactory
Sets the factory used to create feature types. -
setFeatureFactory
Sets the factory used to create features. -
getFilterFactory
The factory used to create filters. -
getFeatureFactory
The factory used to create features. -
setFilterFactory
Sets the factory used to create filters. -
getGeometryFactory
The factory used to create geometries. -
setGeometryFactory
Sets the factory used to create geometries. -
getDataStoreFactory
Returns the factory used to create the data store.- Returns:
- The data store factory, possibly
null.
-
setDataStoreFactory
Sets the data store factory used to create the datastore.WARNING: This property should only be set in cases where the datastore factory is stateless and does not maintain any references to created datastores. Setting this property in such a case will result in a memory leak.
-
getNamespaceURI
The namespace uri of the datastore.- Returns:
- The namespace uri, may be
null.
-
setNamespaceURI
Sets the namespace uri of the datastore.This will be used to qualify the entries or types of the datastore.
- Parameters:
namespaceURI- The namespace uri, may benull.
-
getLogger
The logger for the datastore. -
getInfo
Description copied from interface:DataAccessInformation about this service.This method offers access to a summary of header or metadata information describing the service. Subclasses may return a specific ServiceInfo instance that has additional information (such as FilterCapabilities).
- Specified by:
getInfoin interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Returns:
- SeviceInfo
-
getTypeNames
Returns the names of all entries or types provided by the datastore.This method is marked final and delegates to
createTypeNames(), which subclasses are intended to implement.- Specified by:
getTypeNamesin interfaceDataStore- Returns:
- names of feature types available in this
DataStore - Throws:
IOException- if data access errors occur- See Also:
-
createSchema
Creates a new schema in the datastore.This implementation throws a
UnsupportedOperationException. Subclasses should override to support schema creation.- Specified by:
createSchemain interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Parameters:
featureType- FetureType to add to DataStore- Throws:
IOException- If featureType cannot be created- See Also:
-
getSchema
Returns the feature type or schema matching the specified name.This method calls through to
getFeatureSource(typeName).getSchema()- Specified by:
getSchemain interfaceDataStore- Parameters:
typeName- the feature type name- Returns:
- the requested feature type
- Throws:
IOException- iftypeNameis not available- See Also:
-
getFeatureSource
Returns the feature source matching the specified name.Subclasses should not implement this method. However overriding in order to perform a type narrowing to a subclasses of
ContentFeatureSourceis acceptable.- Specified by:
getFeatureSourcein interfaceDataStore- Parameters:
typeName- the feature type- Returns:
- a
SimpleFeatureSource(or possibly a subclass) providing operations for features of the specified type - Throws:
IOException- if data access errors occur- See Also:
-
getFeatureSource
Returns the feature source matching the specified name and explicitly specifies a transaction.Subclasses should not implement this method. However overriding in order to perform a type narrowing to a subclasses of
ContentFeatureSourceis acceptable.- Throws:
IOException- See Also:
-
getFeatureSource
Returns the feature source matching the specified name and explicitly specifies a transaction.Subclasses should not implement this method. However overriding in order to perform a type narrowing to a subclasses of
ContentFeatureSourceis acceptable.- Throws:
IOException- See Also:
-
getFeatureReader
public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query, Transaction tx) throws IOException Returns a feature reader for the specified query and transaction.This method is not intended to be overridden and is marked final. This implementation delegates to
FeatureCollectionand wraps an iterator in aFeatureReader.- Specified by:
getFeatureReaderin interfaceDataStore- Parameters:
query- a query providing the schema and constraints for features that the reader will returntx- a transaction that this reader will operate against- Returns:
- an instance of
FeatureReader - Throws:
IOException- if data access errors occur
-
getFeatureWriter
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Filter filter, Transaction tx) throws IOException Returns a feature writer for the specified query and transaction.This method is not intended to be overridden and is marked final. This implementation delegates to
FeatureCollectionand wraps an iterator in aFeatureWriter.- Specified by:
getFeatureWriterin interfaceDataStore- Parameters:
typeName- the type name for features that will be accessiblefilter- defines additional constraints on the features that will be accessibletx- the transaction that the returned writer operates against- Returns:
- an instance of
FeatureWriter - Throws:
IOException- if data access errors occur- See Also:
-
ensureFeatureStore
protected final ContentFeatureStore ensureFeatureStore(String typeName, Transaction tx) throws IOException Helper method which gets a feature source ensuring that it is a feature store as well. If not it throws an IOException.- Parameters:
typeName- The name of the feature source.tx- A transaction handle.- Throws:
IOException- If the feature source is not a store.
-
getFeatureWriter
public final FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Transaction tx) throws IOException Returns a feature writer for the specified type name and transaction.This method is convenience for
getFeatureWriter(typeName,Filter.INCLUDE,tx).- Specified by:
getFeatureWriterin interfaceDataStore- Parameters:
typeName- the type name for features that will be accessibletx- the transaction that the returned writer operates against- Returns:
- an instance of
FeatureWriter - Throws:
IOException- if data access errors occur- See Also:
-
getFeatureWriterAppend
public final FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(String typeName, Transaction tx) throws IOException Returns an appending feature writer for the specified type name and transaction.This method is not intended to be overridden and is marked final. This implementation delegates to
FeatureCollectionand wraps an iterator in aFeatureWriter.- Specified by:
getFeatureWriterAppendin interfaceDataStore- Parameters:
typeName- name of the feature type for which features will be addedtx- the transaction to operate against- Returns:
- an instance of
FeatureWriterthat can only be used to append new features - Throws:
IOException- if data access errors occur
-
getLockingManager
Description copied from interface:DataStoreRetrieve a per featureID based locking service from thisDataStore.- Specified by:
getLockingManagerin interfaceDataStore- Returns:
- an instance of
LockingManager; ornullif locking is handled by theDataStorein a different fashion
-
updateSchema
Description copied from interface:DataStoreApplies a new schema to the given feature type. This can be used to add or remove properties. The resulting update will be persistent.- Specified by:
updateSchemain interfaceDataStore- Parameters:
typeName- name of the feature type to updatefeatureType- the new schema to apply- Throws:
IOException- on error
-
dispose
public void dispose()Description copied from interface:DataAccessDisposes of this data store and releases any resource that it is using.A
DataStorecannot be used afterdisposehas been called, neither can any data access object it helped create, such asFeatureReader,FeatureSourceorFeatureCollection.This operation can be called more than once without side effects.
There is no thread safety assurance associated with this method. For example, client code will have to make sure this method is not called while retrieving/saving data from/to the storage, or be prepared for the consequences.
- Specified by:
disposein interfaceDataAccess<SimpleFeatureType,SimpleFeature>
-
getEntry
Returns the entry for a specified name, ornullif no such entry exists. -
createContentState
Instantiates a new content state for the entry.Subclasses may override this method to return a specific subclass of
ContentState.- Parameters:
entry- The entry.- Returns:
- A new instance of
ContentStatefor the entry.
-
name
Helper method to wrap a non-qualified name. -
entry
Helper method to look up an entry in the datastore.This method will create a new instance of
ContentEntryif one does not exist.In the event that the name does not map to an entry and one cannot be created
nullwill be returned. Note that#ensureEntry(TypeName)will throw an exception in this case.- Parameters:
name- The name of the entry.- Returns:
- The entry, or
nullif it does not exist. - Throws:
IOException
-
ensureEntry
Helper method to look up an entry in the datastore which throws anIOExceptionin the event that the entry does not exist.- Parameters:
name- The name of the entry.- Returns:
- The entry.
- Throws:
IOException- If the entry does not exist, or if there was an error looking it up.
-
removeEntry
Helper method to remove an entry from the cached entry map.- Parameters:
name- The name of the entry.
-
createTypeNames
Creates a set of qualified names corresponding to the types that the datastore provides.Namespaces may be left
nullfor data stores which do not support namespace qualified type names.- Returns:
- A list of
Name. - Throws:
IOException- Any errors occuring connecting to data.
-
createFeatureSource
Instantiates new feature source for the entry.Subclasses should override this method to return a specific subclass of
ContentFeatureSource.- Parameters:
entry- The entry.- Returns:
- An new instance of
ContentFeatureSourcefor the entry. - Throws:
IOException
-
getFeatureSource
Delegates togetFeatureSource(Name, Transaction)- Specified by:
getFeatureSourcein interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Specified by:
getFeatureSourcein interfaceDataStore- Parameters:
typeName- the qualified name of the feature type- Returns:
- a
SimpleFeatureSource(or possibly a subclass) providing operations for features of the specified type - Throws:
IOException- if data access errors occur- Since:
- 2.5
- See Also:
-
getNames
Returns the same list of names thangetTypeNames()meaning the returned Names have no namespace set.- Specified by:
getNamesin interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Returns:
- Names of the available contents.
- Throws:
IOException- Since:
- 2.5
- See Also:
-
getSchema
Delegates togetSchema(String)withname.getLocalPart()- Specified by:
getSchemain interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Parameters:
name- Type name a the resource from getNames()- Returns:
- Description of the FeatureType being made avaialble
- Throws:
IOException- Since:
- 2.5
- See Also:
-
updateSchema
Delegates toupdateSchema(String, SimpleFeatureType)withname.getLocalPart()- Specified by:
updateSchemain interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Throws:
IOException- if the operation failed- Since:
- 2.5
- See Also:
-
removeSchema
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> - Throws:
IOException- if the operation failed- See Also:
-
removeSchema
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- Throws:
IOException- if the operation failed- See Also:
-