Class DataStores

Object
Static
DataStores

public final class DataStores extends Static
Static convenience methods creating Data­Store instances from a given storage object. Storage objects are typically File or Data­Source instances, but can also be any other objects documented in the Storage­Connector class.
Since:
0.4
  • Method Details

    • providers

      public static Collection<DataStoreProvider> 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

      public static String probeContentType(Object storage) throws DataStoreException
      Returns the MIME type of the storage file format, or null 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:
      Data­Store­Exception - if an error occurred while opening the storage.
    • open

      public static DataStore open(Object storage) throws UnsupportedStorageException, DataStoreException
      Creates a Data­Store capable to read the given storage. The storage argument can be any of the following types:
      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:
      Unsupported­Storage­Exception - if no Data­Store­Provider is found for the given storage object.
      Data­Store­Exception - if an error occurred while opening the storage in read mode.
    • openWritable

      public static DataStore openWritable(Object storage, String preferredFormat) throws UnsupportedStorageException, DataStoreException
      Creates a Data­Store capable to write or update the given storage. The storage argument can be any of the types documented in open(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 the Writable­Grid­Coverage­Resource, Writable­Feature­Set or Writable­Aggregate interface.

      Format selection

      The preferred­Format 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 Data­Store­Provider is determined by probing the existing content and the preferred­Format argument may be ignored (it can be null). Otherwise the Data­Store­Provider is selected by a combination of preferred­Format (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..
      preferred­Format - the format to use if not determined by the existing content, or null.
      Returns:
      the object to use for writing geospatial data in the given storage.
      Throws:
      Unsupported­Storage­Exception - if no Data­Store­Provider is found for the given storage object.
      Data­Store­Exception - if an error occurred while opening the storage in write mode.
      Since:
      1.4