Class ForwardingDataStore<S extends DataStore>

Object
ForwardingDataStore<S>
Type Parameters:
S - The type of DataStore being decorated
All Implemented Interfaces:
Wrapper, DataAccess<SimpleFeatureType,SimpleFeature>, DataStore, Wrapper
Direct Known Subclasses:
GeoparquetDataStore

public class ForwardingDataStore<S extends DataStore> extends Object implements DataStore, Wrapper
A decorator implementation of the DataStore interface that forwards all method calls to a delegate DataStore instance.

This class is used as a base for creating specialized DataStore implementations that need to modify or extend the behavior of an existing DataStore without modifying the original class.

Some internal workflows — such as the setup of an AggregatorCollection on top of a SimpleFeatureSource — require access to JDBC-specific capabilities. In particular, certain visitors can only be applied if the DataStore is a JDBCDataStore.

The Wrapper interface allows controlled access to the underlying store, making it possible (at the caller’s discretion and risk) to extract the original JDBCDataStore when such specialized handling is needed.

In short: - The wrapper preserves the intent of shielding JDBC internals from general use. - The Wrapper interface makes JDBC access *possible but explicit* for advanced cases. - Callers are responsible for ensuring that any direct JDBC usage does not reintroduce security problems (especially when dealing with user-defined SQL).

  • Field Details

    • delegate

      protected final S extends DataStore delegate
  • Constructor Details

    • ForwardingDataStore

      public ForwardingDataStore(S delegate)
      Creates a new forwarding datastore that delegates all calls to the provided datastore.
      Parameters:
      delegate - The datastore to forward calls to
  • Method Details

    • 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 String[] getTypeNames() throws IOException
      Description copied from interface: DataStore
      Gets the names of feature types available in this DataStore. Please note that this is not guaranteed to return a list of unique names since the same unqualified name may be present in separate namespaces within the DataStore.
      Specified by:
      getTypeNames in interface DataStore
      Returns:
      names of feature types available in this DataStore
      Throws:
      IOException - if data access errors occur
    • getNames

      public List<Name> getNames() throws IOException
      Description copied from interface: DataAccess
      Names of the available Resources.

      For additional information please see getInfo( Name ) and getSchema( Name ).

      Specified by:
      getNames in interface DataAccess<SimpleFeatureType,SimpleFeature>
      Returns:
      Names of the available contents.
      Throws:
      IOException
    • getSchema

      public SimpleFeatureType getSchema(Name name) throws IOException
      Description copied from interface: DataAccess
      Description of the named resource.

      The FeatureType returned describes the contents being published. For additional metadata please review getInfo( Name ).

      Specified by:
      getSchema in interface DataAccess<SimpleFeatureType,SimpleFeature>
      Parameters:
      name - Type name a the resource from getNames()
      Returns:
      Description of the FeatureType being made avaialble
      Throws:
      IOException
    • getSchema

      public SimpleFeatureType getSchema(String typeName) throws IOException
      Description copied from interface: DataStore
      Gets the type information (schema) for the specified feature type.
      Specified by:
      getSchema in interface DataStore
      Parameters:
      typeName - the feature type name
      Returns:
      the requested feature type
      Throws:
      IOException - if typeName is not available
    • getFeatureSource

      public SimpleFeatureSource getFeatureSource(String typeName) throws IOException
      Description copied from interface: DataStore
      Gets a SimpleFeatureSource for features of the specified type. SimpleFeatureSource provides a high-level API for feature operations.

      The resulting SimpleFeatureSource may implment more functionality as in this example:

      
      
       SimpleFeatureSource fsource = dataStore.getFeatureSource("roads");
       if (fsource instanceof SimpleFeatureStore) {
           // we have write access to the feature data
           SimpleFeatureStore fstore = (SimpleFeatureStore) fs;
       }
       else {
           // System.out.println("We do not have write access to roads");
       }
       
      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:
    • getFeatureSource

      public SimpleFeatureSource getFeatureSource(Name typeName) throws IOException
      Description copied from interface: DataStore
      Gets a SimpleFeatureSource for features of the type specified by a qualified name (namespace plus type name).
      Specified by:
      getFeatureSource in interface DataAccess<SimpleFeatureType,SimpleFeature>
      Specified by:
      getFeatureSource in interface DataStore
      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
      See Also:
    • getFeatureReader

      public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query, Transaction transaction) throws IOException
      Description copied from interface: DataStore
      Gets a FeatureReader for features selected by the given Query. FeatureReader provies an iterator-style API to feature data.

      The Query provides the schema for the form of the returned features as well as a Filter to constrain the features available via the reader.

      The Transaction can be used to externalize the state of the DataStore. Examples of this include a JDBCDataStore sharing a connection for use across several FeatureReader requests; and a ShapefileDataStore redirecting requests to an alternate file during the course of a Transaction.

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

      public void createSchema(SimpleFeatureType featureType) throws IOException
      Description copied from interface: DataAccess
      Creates storage for a new featureType.

      The provided featureType we be accessable by the typeName provided by featureType.getTypeName().

      Specified by:
      createSchema in interface DataAccess<SimpleFeatureType,SimpleFeature>
      Parameters:
      featureType - FetureType to add to DataStore
      Throws:
      IOException - If featureType cannot be created
    • updateSchema

      public 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
    • updateSchema

      public void updateSchema(Name typeName, SimpleFeatureType featureType) throws IOException
      Description copied from interface: DataAccess
      Used to update a schema in place.

      This functionality is similar to an "alter table" statement in SQL. Implementation is optional; it may not be supported by all servers or files.

      Specified by:
      updateSchema in interface DataAccess<SimpleFeatureType,SimpleFeature>
      Throws:
      IOException - if the operation failed
    • 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
    • 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
    • getFeatureWriter

      public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Filter filter, Transaction transaction) throws IOException
      Description copied from interface: DataStore
      Gets a FeatureWriter to modify features in this DataStore. FeatureWriter provides an iterator style API to features.

      The returned writer does not allow features to be added.

      Specified by:
      getFeatureWriter in interface DataStore
      Parameters:
      typeName - the type name for features that will be accessible
      filter - defines additional constraints on the features that will be accessible
      transaction - the transaction that the returned writer operates against
      Returns:
      an instance of FeatureWriter
      Throws:
      IOException - if data access errors occur
      See Also:
    • getFeatureWriter

      public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Transaction transaction) throws IOException
      Description copied from interface: DataStore
      Gets a FeatureWriter to modify features in this DataStore. FeatureWriter provides an iterator style API to features.

      The returned writer does not allow features to be added.

      Specified by:
      getFeatureWriter in interface DataStore
      Parameters:
      typeName - the type name for features that will be accessible
      transaction - the transaction that the returned writer operates against
      Returns:
      an instance of FeatureWriter
      Throws:
      IOException - if data access errors occur
      See Also:
    • getFeatureWriterAppend

      public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriterAppend(String typeName, Transaction transaction) throws IOException
      Description copied from interface: DataStore
      Gets a FeatureWriter that can add new features to the DataStore.

      The FeatureWriter will return false when its hasNext() method is called, but next() can be used to acquire new features.

      Specified by:
      getFeatureWriterAppend in interface DataStore
      Parameters:
      typeName - name of the feature type for which features will be added
      transaction - 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 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
    • isWrapperFor

      public boolean isWrapperFor(Class<?> aClass)
      Description copied from interface: Wrapper
      Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does. Returns false otherwise. If this implements the interface then return true, else if this is a wrapper then return the result of recursively calling isWrapperFor on the wrapped object. If this does not implement the interface and is not a wrapper, return false. This method should be implemented as a low-cost operation compared to unwrap so that callers can use this method to avoid expensive unwrap calls that may fail. If this method returns true then calling unwrap with the same argument should succeed.
      Specified by:
      isWrapperFor in interface Wrapper
      Specified by:
      isWrapperFor in interface Wrapper
      Parameters:
      aClass - a Class defining an interface.
      Returns:
      true if this implements the interface or directly or indirectly wraps an object that does.
    • unwrap

      public <T> T unwrap(Class<T> aClass) throws IllegalArgumentException
      Description copied from interface: Wrapper
      Returns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.

      If the receiver implements the interface then the result is the receiver or a proxy for the receiver. If the receiver is a wrapper and the wrapped object implements the interface then the result is the wrapped object or a proxy for the wrapped object. Otherwise return the the result of calling unwrap recursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then an IllegalArgumentException is thrown.

      Specified by:
      unwrap in interface Wrapper
      Specified by:
      unwrap in interface Wrapper
      Parameters:
      aClass - A Class defining an interface that the result must implement.
      Returns:
      an object that implements the interface. May be a proxy for the actual implementing object.
      Throws:
      IllegalArgumentException - If no object found that implements the interface