Class Store
java.lang.Object
org.apache.sis.storage.DataStore
org.apache.sis.internal.storage.URIDataStore
org.apache.sis.internal.storage.xml.Store
- All Implemented Interfaces:
AutoCloseable,Filter,ResourceOnFileSystem,StoreResource,Resource,Localized
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 byMetadata.getReferenceSystemInfo().
- Since:
- 0.4
- Version:
- 1.3
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.sis.internal.storage.URIDataStore
URIDataStore.Provider -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.opengis.metadata.MetadataThe metadata object, determined when first needed.private ObjectThe unmarshalled object, initialized only when first needed.private StreamSourceThe input stream or reader, set by the constructor and cleared when no longer needed.Fields inherited from class org.apache.sis.internal.storage.URIDataStore
location -
Constructor Summary
ConstructorsConstructorDescriptionStore(StoreProvider provider, StorageConnector connector) Creates a new XML store from the given file, URL or stream. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes this data store and releases any underlying resources.org.opengis.metadata.MetadataReturns the metadata associated to the unmarshalled object, ornullif none.private static Closeableinput(StreamSource source) Returns the input stream or reader set in the given source, ornullif none.booleanisLoggable(LogRecord warning) Intercepts warnings produced during the (un)marshalling process and redirect them to the listeners.private voidReports a warning, if non-null.Returns the properties to give to the (un)marshaller.private voidUnmarshal the object, if not already done.Methods inherited from class org.apache.sis.internal.storage.URIDataStore
addTitleOrIdentifier, getComponentFiles, getIdentifier, getOpenParameters, getOriginator, getSpecifiedPath, location, parametersMethods inherited from class org.apache.sis.storage.DataStore
addListener, findResource, getDisplayName, getLocale, getNativeMetadata, getProvider, removeListener, setLocale, toStringMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.sis.storage.Resource
addListener, removeListener
-
Field Details
-
source
The input stream or reader, set by the constructor and cleared when no longer needed. -
object
The unmarshalled object, initialized only when first needed. May still benullif the unmarshalling failed. -
metadata
private org.opengis.metadata.Metadata metadataThe metadata object, determined when first needed.
-
-
Constructor Details
-
Store
Creates a new XML store from the given file, URL or stream.- Parameters:
provider- the factory that created thisDataStoreinstance, ornullif unspecified.connector- information about the storage (URL, stream, etc).- Throws:
DataStoreException- if an error occurred while opening the stream.
-
-
Method Details
-
input
Returns the input stream or reader set in the given source, ornullif none. -
properties
Returns the properties to give to the (un)marshaller. -
isLoggable
Intercepts warnings produced during the (un)marshalling process and redirect them to the listeners. This method is public as an implementation convenience forproperties()method; it should not be invoked directly.- Specified by:
isLoggablein interfaceFilter- Parameters:
warning- the warning that occurred during (un)marshalling.- Returns:
- always
falsesince logging will be handled bylisteners.
-
unmarshal
Unmarshal the object, if not already done. Note thatobjectmay 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
Reports a warning, if non-null. -
getMetadata
Returns the metadata associated to the unmarshalled object, ornullif none. The current implementation performs the following choice:- If the unmarshalled object implements the
Metadatainterface, then it is returned directly. - Otherwise if the unmarshalled object implements
ReferenceSystem, then it is wrapped in the "reference system info" property of a newDefaultMetadatainstance.
- Specified by:
getMetadatain interfaceResource- Specified by:
getMetadatain classDataStore- Returns:
- the metadata associated to the unmarshalled object, or
nullif none. - Throws:
DataStoreException- if an error occurred during the unmarshalling process.- See Also:
- If the unmarshalled object implements the
-
close
Closes this data store and releases any underlying resources.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein classDataStore- Throws:
DataStoreException- if an error occurred while closing this data store.- See Also:
-