Class ForwardingDataStore<S extends DataStore>
- Type Parameters:
S- The type of DataStore being decorated
- All Implemented Interfaces:
Wrapper,DataAccess<SimpleFeatureType,,SimpleFeature> DataStore,Wrapper
- Direct Known Subclasses:
GeoparquetDataStore
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 Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionForwardingDataStore(S delegate) Creates a new forwarding datastore that delegates all calls to the provided datastore. -
Method Summary
Modifier and TypeMethodDescriptionvoidcreateSchema(SimpleFeatureType featureType) Creates storage for a newfeatureType.voiddispose()Disposes of this data store and releases any resource that it is using.getFeatureReader(Query query, Transaction transaction) Gets aFeatureReaderfor features selected by the givenQuery.getFeatureSource(String typeName) Gets aSimpleFeatureSourcefor features of the specified type.getFeatureSource(Name typeName) Gets aSimpleFeatureSourcefor features of the type specified by a qualified name (namespace plus type name).getFeatureWriter(String typeName, Transaction transaction) Gets aFeatureWriterto modify features in thisDataStore.getFeatureWriter(String typeName, Filter filter, Transaction transaction) Gets aFeatureWriterto modify features in thisDataStore.getFeatureWriterAppend(String typeName, Transaction transaction) Gets aFeatureWriterthat can add new features to theDataStore.getInfo()Information about this service.Retrieve a per featureID based locking service from thisDataStore.getNames()Names of the available Resources.Gets the type information (schema) for the specified feature type.Description of the named resource.String[]Gets the names of feature types available in thisDataStore.booleanisWrapperFor(Class<?> aClass) Returns true if this either implements the interface argument or is directly or indirectly a wrapper for an object that does.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<T> TReturns an object that implements the given interface to allow access to non-standard methods, or standard methods not exposed by the proxy.voidupdateSchema(String typeName, SimpleFeatureType featureType) Applies a new schema to the given feature type.voidupdateSchema(Name typeName, SimpleFeatureType featureType) Used to update a schema in place.
-
Field Details
-
delegate
-
-
Constructor Details
-
ForwardingDataStore
Creates a new forwarding datastore that delegates all calls to the provided datastore.- Parameters:
delegate- The datastore to forward calls to
-
-
Method Details
-
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
Description copied from interface:DataStoreGets the names of feature types available in thisDataStore. 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 theDataStore.- Specified by:
getTypeNamesin interfaceDataStore- Returns:
- names of feature types available in this
DataStore - Throws:
IOException- if data access errors occur
-
getNames
Description copied from interface:DataAccessNames of the available Resources.For additional information please see getInfo( Name ) and getSchema( Name ).
- Specified by:
getNamesin interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Returns:
- Names of the available contents.
- Throws:
IOException
-
getSchema
Description copied from interface:DataAccessDescription of the named resource.The FeatureType returned describes the contents being published. For additional metadata please review getInfo( Name ).
- 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
-
getSchema
Description copied from interface:DataStoreGets the type information (schema) for the specified feature type.- Specified by:
getSchemain interfaceDataStore- Parameters:
typeName- the feature type name- Returns:
- the requested feature type
- Throws:
IOException- iftypeNameis not available
-
getFeatureSource
Description copied from interface:DataStoreGets aSimpleFeatureSourcefor features of the specified type.SimpleFeatureSourceprovides a high-level API for feature operations.The resulting
SimpleFeatureSourcemay 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:
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
Description copied from interface:DataStoreGets aSimpleFeatureSourcefor features of the type specified by a qualified name (namespace plus type name).- 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- See Also:
-
getFeatureReader
public FeatureReader<SimpleFeatureType,SimpleFeature> getFeatureReader(Query query, Transaction transaction) throws IOException Description copied from interface:DataStoreGets aFeatureReaderfor features selected by the givenQuery.FeatureReaderprovies an iterator-style API to feature data.The
Queryprovides the schema for the form of the returned features as well as aFilterto constrain the features available via the reader.The
Transactioncan be used to externalize the state of theDataStore. Examples of this include aJDBCDataStoresharing a connection for use across severalFeatureReaderrequests; and aShapefileDataStoreredirecting requests to an alternate file during the course of aTransaction.- Specified by:
getFeatureReaderin interfaceDataStore- Parameters:
query- a query providing the schema and constraints for features that the reader will returntransaction- 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: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>
-
createSchema
Description copied from interface:DataAccessCreates storage for a newfeatureType.The provided
featureTypewe be accessable by the typeName provided by featureType.getTypeName().- Specified by:
createSchemain interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Parameters:
featureType- FetureType to add to DataStore- Throws:
IOException- If featureType cannot be created
-
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
-
updateSchema
Description copied from interface:DataAccessUsed 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:
updateSchemain interfaceDataAccess<SimpleFeatureType,SimpleFeature> - Throws:
IOException- if the operation failed
-
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
-
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
-
getFeatureWriter
public FeatureWriter<SimpleFeatureType,SimpleFeature> getFeatureWriter(String typeName, Filter filter, Transaction transaction) throws IOException Description copied from interface:DataStoreGets aFeatureWriterto modify features in thisDataStore.FeatureWriterprovides an iterator style API to features.The returned writer does not allow features to be added.
- Specified by:
getFeatureWriterin interfaceDataStore- Parameters:
typeName- the type name for features that will be accessiblefilter- defines additional constraints on the features that will be accessibletransaction- 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:DataStoreGets aFeatureWriterto modify features in thisDataStore.FeatureWriterprovides an iterator style API to features.The returned writer does not allow features to be added.
- Specified by:
getFeatureWriterin interfaceDataStore- Parameters:
typeName- the type name for features that will be accessibletransaction- 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:DataStoreGets aFeatureWriterthat can add new features to theDataStore.The
FeatureWriterwill returnfalsewhen itshasNext()method is called, butnext()can be used to acquire new features.- Specified by:
getFeatureWriterAppendin interfaceDataStore- Parameters:
typeName- name of the feature type for which features will be addedtransaction- 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
-
isWrapperFor
Description copied from interface:WrapperReturns 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 callingisWrapperForon 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 tounwrapso that callers can use this method to avoid expensiveunwrapcalls that may fail. If this method returns true then callingunwrapwith the same argument should succeed.- Specified by:
isWrapperForin interfaceWrapper- Specified by:
isWrapperForin interfaceWrapper- Parameters:
aClass- a Class defining an interface.- Returns:
- true if this implements the interface or directly or indirectly wraps an object that does.
-
unwrap
Description copied from interface:WrapperReturns 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
unwraprecursively on the wrapped object or a proxy for that result. If the receiver is not a wrapper and does not implement the interface, then anIllegalArgumentExceptionis thrown.- Specified by:
unwrapin interfaceWrapper- Specified by:
unwrapin interfaceWrapper- 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
-