Static convenience methods creating
DataStore
instances from a given storage object.
Storage objects are typically File
or DataSource
instances,
but can also be any other objects documented in the StorageConnector
class.- Since:
- 0.4
-
Method Summary
Modifier and TypeMethodDescriptionstatic DataStore
Creates aDataStore
capable to read the given storage.static DataStore
openWritable
(Object storage, String preferredFormat) Creates aDataStore
capable to write or update the given storage.static String
probeContentType
(Object storage) Returns the MIME type of the storage file format, ornull
if unknown or not applicable.static Collection
<DataStoreProvider> Returns the set of available data store providers.
-
Method Details
-
providers
Returns the set of available data store providers. The returned collection is live: its content may change if new modules are added on the module path at run-time.- Returns:
- descriptions of available data stores.
- Since:
- 0.8
-
probeContentType
Returns the MIME type of the storage file format, ornull
if unknown or not applicable.- Parameters:
storage
- the input/output object as a URL, file, image input stream, etc..- Returns:
- the storage MIME type, or
null
if unknown or not applicable. - Throws:
DataStoreException
- if an error occurred while opening the storage.
-
open
Creates aDataStore
capable to read the given storage. Thestorage
argument can be any of the following types:- A
Path
or aFile
for a file or a directory. - A
URI
or aURL
to a distant resource. - A
CharSequence
interpreted as a filename or a URL. - A
Channel
,DataInput
,InputStream
orReader
. - A
DataSource
or aConnection
to a JDBC database. - Any other
DataStore
-specific object, for exampleNetcdfFile
. - An existing
StorageConnector
instance.
- Parameters:
storage
- the input object as a URL, file, image input stream, etc..- Returns:
- the object to use for reading geospatial data from the given storage.
- Throws:
UnsupportedStorageException
- if noDataStoreProvider
is found for the given storage object.DataStoreException
- if an error occurred while opening the storage in read mode.
- A
-
openWritable
public static DataStore openWritable(Object storage, String preferredFormat) throws UnsupportedStorageException, DataStoreException Creates aDataStore
capable to write or update the given storage. Thestorage
argument can be any of the types documented inopen(Object)
. If the storage is a file and that file does not exist, then a new file will be created. If the storage exists, then it will be opened in read/write mode for updates. The returned data store should implement theWritableGridCoverageResource
,WritableFeatureSet
orWritableAggregate
interface.Format selection
ThepreferredFormat
argument can be a data store name (examples:"CSV"
,"GPX"
) or an Image I/O name (examples:"TIFF"
,"PNG"
). In the latter case, the WorldFile convention is used.If the given storage exists (for example, an existing file), then the
DataStoreProvider
is determined by probing the existing content and thepreferredFormat
argument may be ignored (it can benull
). Otherwise theDataStoreProvider
is selected by a combination ofpreferredFormat
(if non-null) and file suffix (if the storage is a file path or URI).- Parameters:
storage
- the input/output object as a URL, file, image input stream, etc..preferredFormat
- the format to use if not determined by the existing content, ornull
.- Returns:
- the object to use for writing geospatial data in the given storage.
- Throws:
UnsupportedStorageException
- if noDataStoreProvider
is found for the given storage object.DataStoreException
- if an error occurred while opening the storage in write mode.- Since:
- 1.4
-