Class SimpleFeatureStore
- All Implemented Interfaces:
AutoCloseable, Aggregate, Resource, Localized
A concrete data store capable to read and write features from/to a spatial SQL database.
All resources created by this class are
FeatureSets.
The data are specified by two main arguments given at construction time:
- A
DataSource(specified indirectly) providing connections to the database. While not mandatory, a pooled data source is recommended becauseSimpleFeatureStoremay open and close connections many times. - A list of tables, views or queries to view as
FeatureSets. This list is provided byResourceDefinitionobjects. Only the main tables need to be specified. Dependencies inferred by foreigner keys will be followed automatically.
SimpleFeatureStore class name, this class supports complex features,
i.e. features having associations to other features.
The associations are discovered automatically by following the foreigner keys.- Since:
- 1.5
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface Resource
Resource.FileSetModifier and TypeInterfaceDescriptionstatic classPaths to the files potentially used by the enclosing resource. -
Field Summary
Fields inherited from class SQLStore
contentLocale, sourceModifier and TypeFieldDescriptionprotected final LocaleThe locale to use for international texts to write in a database table.protected final DataSourceThe data source to use for obtaining connections to the database.Fields inherited from class DataStore
listeners, providerModifier and TypeFieldDescriptionprotected final StoreListenersThe set of registeredStoreListeners for this data store.protected final DataStoreProviderThe factory that created thisDataStoreinstance, ornullif unspecified. -
Constructor Summary
ConstructorsConstructorDescriptionSimpleFeatureStore(DataStoreProvider provider, StorageConnector connector, ResourceDefinition... resources) Creates a newSimpleFeatureStorefor the given data source and tables, views or queries. -
Method Summary
Modifier and TypeMethodDescriptionReturns the tables (feature sets) in this SQL store.findResource(String identifier) Searches for a resource identified by the given identifier.Returns parameters that can be used for opening this Simple Features data store.protected ResourceDefinition[]Returns the resource definitions equivalent to the ones specified at construction time.Methods inherited from class SQLStore
addListener, close, getDatabaseSoftwareVersions, getDataSource, getIdentifier, getMetadata, initialize, newDataAccess, vacuumModifier and TypeMethodDescription<T extends StoreEvent>
voidaddListener(Class<T> eventType, StoreListener<? super T> listener) Registers a listener to notify when the specified kind of event occurs in this data store.voidclose()Closes this SQL store and releases any underlying resources.Returns the version of the database software, together with versions of extensions if any.Returns the data source to use for obtaining connections to the database.Returns an identifier for the root resource of this SQL store, or an empty value if none.Returns information about the dataset as a whole.protected voidinitialize(Connection connection) Invoked the first time thatSQLStoreopens a connection on the database, or after refresh.newDataAccess(boolean write) Creates a new low-level data access object.voidvacuum()Executes the"VACUUM"statement on the database.Methods inherited from class DataStore
getDisplayName, getLocale, getNativeMetadata, getProvider, removeListener, setLocale, toStringModifier and TypeMethodDescriptionReturns a short name or label for this data store.The locale to use for formatting warnings and other messages.Returns implementation-specific metadata.Returns the factory that created thisDataStoreinstance.<T extends StoreEvent>
voidremoveListener(Class<T> eventType, StoreListener<? super T> listener) Unregisters a listener previously added to this data store for the given type of events.voidsetLocale(Locale locale) Sets the locale to use for formatting warnings and other messages.Returns a string representation of this data store for debugging purpose.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface Resource
getFileSetModifier and TypeMethodDescriptiondefault Optional<Resource.FileSet> Gets the paths to the files potentially used by this resource.
-
Constructor Details
-
SimpleFeatureStore
public SimpleFeatureStore(DataStoreProvider provider, StorageConnector connector, ResourceDefinition... resources) throws DataStoreException Creates a newSimpleFeatureStorefor the given data source and tables, views or queries. The givenconnectorshall contain aDataSourceinstance. Tables or views to include in the store are specified by theresourcesargument. Only the main tables need to be specified, as dependencies will be followed automatically.- Parameters:
provider- the factory that created thisDataStoreinstance, ornullif unspecified.connector- information about the storage (JDBC data source, etc).resources- tables, views or queries to include in this store.- Throws:
DataStoreException- if an error occurred while creating the data store for the given storage.
-
-
Method Details
-
getOpenParameters
Returns parameters that can be used for opening this Simple Features data store. The parameters are described bySQLStoreProvider.getOpenParameters()and can contain some or all of the following:- A parameter named "location" with a
DataSourcevalue. SQLStoreProvider.TABLES_PARAMwithResourceDefinitions specified at construction time for tables.SQLStoreProvider.QUERIES_PARAMwithResourceDefinitions specified at construction time for queries.
- Overrides:
getOpenParametersin classSQLStore- Returns:
- parameters used for opening this data store.
- See Also:
- A parameter named "location" with a
-
components
Returns the tables (feature sets) in this SQL store. The collection contains only the tables matching aResourceDefinitiongiven at construction time.- Specified by:
componentsin interfaceAggregate- Overrides:
componentsin classSQLStore- Returns:
- children resources that are components of this SQL store.
- Throws:
DataStoreException- if an error occurred while fetching the components.
-
findResource
Searches for a resource identified by the given identifier. The given identifier shall match the name of one of the tables, views or queries inferred at construction time. It may be a table named explicitly at construction time, or a dependency inferred by following foreigner keys. The given identifier may be qualified with the schema name, or may be only the table name if there is no ambiguity.- Overrides:
findResourcein classSQLStore- Parameters:
identifier- identifier of the resource to fetch. Must be non-null.- Returns:
- resource associated with the given identifier (never
null). - Throws:
IllegalNameException- if no resource is found for the given identifier, or if more than one resource is found.DataStoreException- if another kind of error occurred while searching resources.- See Also:
-
readResourceDefinitions
Returns the resource definitions equivalent to the ones specified at construction time. This method is defined for completness, but is not used bySimpleFeatureStore.- Specified by:
readResourceDefinitionsin classSQLStore- Parameters:
dao- ignored.- Returns:
- tables or views to include in the store. Only the main tables need to be specified. Dependencies (inferred from the foreigner keys) will be followed automatically.
- See Also:
-