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.Metadata
The metadata object, determined when first needed.private Object
The unmarshalled object, initialized only when first needed.private StreamSource
The 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 TypeMethodDescriptionvoid
close()
Closes this data store and releases any underlying resources.org.opengis.metadata.Metadata
Returns the metadata associated to the unmarshalled object, ornull
if none.private static Closeable
input
(StreamSource source) Returns the input stream or reader set in the given source, ornull
if none.boolean
isLoggable
(LogRecord warning) Intercepts warnings produced during the (un)marshalling process and redirect them to the listeners.private void
Reports a warning, if non-null.Returns the properties to give to the (un)marshaller.private void
Unmarshal the object, if not already done.Methods inherited from class org.apache.sis.internal.storage.URIDataStore
addTitleOrIdentifier, getComponentFiles, getIdentifier, getOpenParameters, getOriginator, getSpecifiedPath, location, parameters
Methods inherited from class org.apache.sis.storage.DataStore
addListener, findResource, getDisplayName, getLocale, getNativeMetadata, getProvider, removeListener, setLocale, toString
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods 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 benull
if 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 thisDataStore
instance, ornull
if 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, ornull
if 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:
isLoggable
in interfaceFilter
- Parameters:
warning
- the warning that occurred during (un)marshalling.- Returns:
- always
false
since logging will be handled bylisteners
.
-
unmarshal
Unmarshal the object, if not already done. Note thatobject
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
Reports a warning, if non-null. -
getMetadata
Returns the metadata associated to the unmarshalled object, ornull
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 newDefaultMetadata
instance.
- Specified by:
getMetadata
in interfaceResource
- Specified by:
getMetadata
in classDataStore
- Returns:
- the metadata associated to the unmarshalled object, or
null
if 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:
close
in interfaceAutoCloseable
- Specified by:
close
in classDataStore
- Throws:
DataStoreException
- if an error occurred while closing this data store.- See Also:
-