All Implemented Interfaces:
AutoCloseable, Filter, ResourceOnFileSystem, StoreResource, Resource, Localized

final class Store extends URIDataStore implements Filter
A data store which creates data objects from a XML file. This DataStore implementation is basically a facade for the XML.unmarshal(Source, Map) method. The current implementation recognizes the following objects:
  • Metadata, typically built from the <mdb:MD_Metadata> XML element.
  • ReferenceSystem, accessible by Metadata.getReferenceSystemInfo().
The above list may be extended in any future SIS version.
Since:
0.4
Version:
1.3
  • Field Details

    • source

      private StreamSource source
      The input stream or reader, set by the constructor and cleared when no longer needed.
    • object

      private Object object
      The unmarshalled object, initialized only when first needed. May still be null if the unmarshalling failed.
    • metadata

      private org.opengis.metadata.Metadata metadata
      The metadata object, determined when first needed.
  • Constructor Details

    • Store

      public Store(StoreProvider provider, StorageConnector connector) throws DataStoreException
      Creates a new XML store from the given file, URL or stream.
      Parameters:
      provider - the factory that created this DataStore instance, or null if unspecified.
      connector - information about the storage (URL, stream, etc).
      Throws:
      DataStoreException - if an error occurred while opening the stream.
  • Method Details

    • input

      private static Closeable input(StreamSource source)
      Returns the input stream or reader set in the given source, or null if none.
    • properties

      private Map<String,?> properties()
      Returns the properties to give to the (un)marshaller.
    • isLoggable

      public boolean isLoggable(LogRecord warning)
      Intercepts warnings produced during the (un)marshalling process and redirect them to the listeners. This method is public as an implementation convenience for properties() method; it should not be invoked directly.
      Specified by:
      isLoggable in interface Filter
      Parameters:
      warning - the warning that occurred during (un)marshalling.
      Returns:
      always false since logging will be handled by listeners.
    • unmarshal

      private void unmarshal() throws DataStoreException
      Unmarshal the object, if not already done. Note that object may still be null if an exception has been thrown at this invocation time or in previous invocation.
      Throws:
      DataStoreException - if an error occurred during the unmarshalling process.
    • log

      private void log(LogRecord record)
      Reports a warning, if non-null.
    • getMetadata

      public org.opengis.metadata.Metadata getMetadata() throws DataStoreException
      Returns the metadata associated to the unmarshalled object, or null if none. The current implementation performs the following choice:
      • If the unmarshalled object implements the Metadata interface, then it is returned directly.
      • Otherwise if the unmarshalled object implements ReferenceSystem, then it is wrapped in the "reference system info" property of a new DefaultMetadata instance.
      Other cases may be added in any future SIS version.
      Specified by:
      getMetadata in interface Resource
      Specified by:
      getMetadata in class DataStore
      Returns:
      the metadata associated to the unmarshalled object, or null if none.
      Throws:
      DataStoreException - if an error occurred during the unmarshalling process.
      See Also:
    • close

      public void close() throws DataStoreException
      Closes this data store and releases any underlying resources.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in class DataStore
      Throws:
      DataStoreException - if an error occurred while closing this data store.
      See Also: