Class ContentDataStore

    • Field Detail

      • JOINED_FEATURE_TYPE

        public static final String 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:
        Constant Field Values
      • WRITER_ADD

        protected static final int WRITER_ADD
        Flag writer for adding new content
        See Also:
        Constant Field Values
      • WRITER_UPDATE

        protected static final int WRITER_UPDATE
        Flag writer for updating content in place
        See Also:
        Constant Field Values
      • WRITER_COMMIT

        protected static final int WRITER_COMMIT
        Flag writer for commit (AUTO_COMMIT with no events)
        See Also:
        Constant Field Values
      • LOGGER

        protected final Logger LOGGER
        logger
      • typeFactory

        protected FeatureTypeFactory typeFactory
        Factory used to create feature types
      • featureFactory

        protected FeatureFactory featureFactory
        Factory used to create features
      • filterFactory

        protected FilterFactory filterFactory
        Factory used to create filters
      • geometryFactory

        protected GeometryFactory geometryFactory
        Factory used to create geometries
      • namespaceURI

        protected String namespaceURI
        namespace uri of the datastore itself, or default namespace
      • lockingManager

        protected LockingManager lockingManager
        locking manager
      • dataStoreFactory

        protected DataStoreFactorySpi dataStoreFactory
        factory used to create the datastore
    • Constructor Detail

      • ContentDataStore

        public ContentDataStore()
    • Method Detail

      • getFeatureTypeFactory

        public FeatureTypeFactory getFeatureTypeFactory()
        The factory used to create feature types.
      • setFeatureTypeFactory

        public void setFeatureTypeFactory​(FeatureTypeFactory typeFactory)
        Sets the factory used to create feature types.
      • setFeatureFactory

        public void setFeatureFactory​(FeatureFactory featureFactory)
        Sets the factory used to create features.
      • getFilterFactory

        public FilterFactory getFilterFactory()
        The factory used to create filters.
      • getFeatureFactory

        public FeatureFactory getFeatureFactory()
        The factory used to create features.
      • setFilterFactory

        public void setFilterFactory​(FilterFactory filterFactory)
        Sets the factory used to create filters.
      • getGeometryFactory

        public GeometryFactory getGeometryFactory()
        The factory used to create geometries.
      • setGeometryFactory

        public void setGeometryFactory​(GeometryFactory geometryFactory)
        Sets the factory used to create geometries.
      • getDataStoreFactory

        public DataStoreFactorySpi getDataStoreFactory()
        Returns the factory used to create the data store.
        Returns:
        The data store factory, possibly null.
      • setDataStoreFactory

        public void setDataStoreFactory​(DataStoreFactorySpi dataStoreFactory)
        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

        public String getNamespaceURI()
        The namespace uri of the datastore.
        Returns:
        The namespace uri, may be null.
      • setNamespaceURI

        public void setNamespaceURI​(String namespaceURI)
        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 be null.
      • getLogger

        public Logger getLogger()
        The logger for the datastore.
      • getInfo

        public ServiceInfo getInfo()
        Description copied from interface: DataAccess
        Information 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:
        getInfo in interface DataAccess<SimpleFeatureType,​SimpleFeature>
        Returns:
        SeviceInfo
      • getTypeNames

        public final String[] getTypeNames()
                                    throws IOException
        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:
        getTypeNames in interface DataStore
        Returns:
        names of feature types available in this DataStore
        Throws:
        IOException - if data access errors occur
        See Also:
        DataStore.getTypeNames()
      • getSchema

        public final SimpleFeatureType getSchema​(String typeName)
                                          throws IOException
        Returns the feature type or schema matching the specified name.

        This method calls through to getFeatureSource(typeName).getSchema()

        Specified by:
        getSchema in interface DataStore
        Parameters:
        typeName - the feature type name
        Returns:
        the requested feature type
        Throws:
        IOException - if typeName is not available
        See Also:
        DataStore.getSchema(String)
      • getFeatureSource

        public ContentFeatureSource getFeatureSource​(String typeName)
                                              throws IOException
        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 ContentFeatureSource is acceptable.

        Specified by:
        getFeatureSource in interface DataStore
        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:
        DataStore.getFeatureSource(String)
      • getFeatureSource

        public ContentFeatureSource getFeatureSource​(String typeName,
                                                     Transaction tx)
                                              throws IOException
        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 ContentFeatureSource is acceptable.

        Throws:
        IOException
        See Also:
        DataStore.getFeatureSource(String)
      • 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 FeatureCollection and wraps an iterator in a FeatureReader.

        Specified by:
        getFeatureReader in interface DataStore
        Parameters:
        query - a query providing the schema and constraints for features that the reader will return
        tx - a transaction that this reader will operate against
        Returns:
        an instance of FeatureReader
        Throws:
        IOException - if data access errors occur
      • 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.
      • 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 FeatureCollection and wraps an iterator in a FeatureWriter.

        Specified by:
        getFeatureWriterAppend in interface DataStore
        Parameters:
        typeName - name of the feature type for which features will be added
        tx - the transaction to operate against
        Returns:
        an instance of FeatureWriter that can only be used to append new features
        Throws:
        IOException - if data access errors occur
      • getLockingManager

        public final LockingManager getLockingManager()
        Description copied from interface: DataStore
        Retrieve a per featureID based locking service from this DataStore.
        Specified by:
        getLockingManager in interface DataStore
        Returns:
        an instance of LockingManager; or null if locking is handled by the DataStore in a different fashion
      • updateSchema

        public final void updateSchema​(String typeName,
                                       SimpleFeatureType featureType)
                                throws IOException
        Description copied from interface: DataStore
        Applies 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:
        updateSchema in interface DataStore
        Parameters:
        typeName - name of the feature type to update
        featureType - the new schema to apply
        Throws:
        IOException - on error
      • dispose

        public void dispose()
        Description copied from interface: DataAccess
        Disposes of this data store and releases any resource that it is using.

        A DataStore cannot be used after dispose has been called, neither can any data access object it helped create, such as FeatureReader, FeatureSource or FeatureCollection.

        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:
        dispose in interface DataAccess<SimpleFeatureType,​SimpleFeature>
      • getEntry

        public ContentEntry getEntry​(Name name)
        Returns the entry for a specified name, or null if no such entry exists.
      • createContentState

        protected ContentState createContentState​(ContentEntry entry)
        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 ContentState for the entry.
      • name

        protected final Name name​(String typeName)
        Helper method to wrap a non-qualified name.
      • entry

        protected final ContentEntry entry​(Name name)
                                    throws IOException
        Helper method to look up an entry in the datastore.

        This method will create a new instance of ContentEntry if one does not exist.

        In the event that the name does not map to an entry and one cannot be created null will be returned. Note that #ensureEntry(TypeName) will throw an exception in this case.

        Parameters:
        name - The name of the entry.
        Returns:
        The entry, or null if it does not exist.
        Throws:
        IOException
      • ensureEntry

        protected final ContentEntry ensureEntry​(Name name)
                                          throws IOException
        Helper method to look up an entry in the datastore which throws an IOException in 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

        protected final void removeEntry​(Name name)
        Helper method to remove an entry from the cached entry map.
        Parameters:
        name - The name of the entry.
      • createTypeNames

        protected abstract List<Name> createTypeNames()
                                               throws IOException
        Creates a set of qualified names corresponding to the types that the datastore provides.

        Namespaces may be left null for data stores which do not support namespace qualified type names.

        Returns:
        A list of Name.
        Throws:
        IOException - Any errors occuring connecting to data.
      • createFeatureSource

        protected abstract ContentFeatureSource createFeatureSource​(ContentEntry entry)
                                                             throws IOException
        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 ContentFeatureSource for the entry.
        Throws:
        IOException
      • removeSchema

        public void removeSchema​(Name typeName)
                          throws IOException
        Description copied from interface: DataAccess
        Used to permanently remove a schema from the underlying storage

        This 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 interface DataAccess<SimpleFeatureType,​SimpleFeature>
        Throws:
        IOException - if the operation failed
        See Also:
        DataAccess.removeSchema(Name)
      • removeSchema

        public void removeSchema​(String typeName)
                          throws IOException
        Description copied from interface: DataStore
        Used to permanently remove a schema from the underlying storage

        This 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 interface DataStore
        Throws:
        IOException - if the operation failed
        See Also:
        DataStore.removeSchema(String)