Class TLcdISO19139MetadataDecoder
- All Implemented Interfaces:
ILcdMetadataDecoder
,ILcdInputStreamFactoryCapable
model
package.
Decoding an ISO 19139 data source using this decoder results in
an instance of a class in the metadata domain model.
Decoding
There are 2 decoding methods available:decodeMetadata(String)
: use this method to decode a source containing a single metadata entity (MD_Metadata)decodeObject(String)
: use this method for all other sources (e.g. aggregate datasets)
Metadata discovery
The findAndDecodeMetadata(String)
} method can find ISO 19139 metadata files that are located next to a
data set, having the same name of the data set source, but with an '.xml' extension instead.
Extensions
This decoder also supports extension schemas of the ISO 19139 schemas. If all schemas are properly referred to in thexsi:schemaLocation
attribute of the files
to decode, the decoder will be able to auto-configure itself for the extension(s) on-the-fly.
Alternatively, the decoder may be pre-configured for a particular extension schema, as illustrated
in the following snippet:
TLcdXMLDataModelBuilder dataModelBuilder = new TLcdXMLDataModelBuilder( TLcdISO19115DataTypes.getDataModel() ); dataModelBuilder.setEntityResolver( new TLcdXMLEntityResolver() ); TLcdDataModel dataModel = dataModelBuilder.createDataModel( "http://myextensionnamespace.com", "http://myextensionnamespace.com", "/myextensionschemalocation.xsd" ); TLcdISO19139MetadataDecoder decoder = new TLcdISO19139MetadataDecoder( dataModel );
Supported versions and specifications
The reference of the currently supported ISO 19139 specification is ISO/TC 19139:2007(E). For more information, see http://www.isotc211.org/. This decoder uses Java's StAX (Streaming API for XML) API. See Oracle's StAX tutorial for more information on the use of StAX.- Since:
- 10.0
- See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.luciad.format.metadata.model.ILcdMetadataDecoder
ILcdMetadataDecoder.MetadataWithSource
-
Constructor Summary
ConstructorDescriptionCreates a newTLcdISO19139MetadataDecoder
instance.TLcdISO19139MetadataDecoder
(TLcdDataModel aDataModel) Creates a newTLcdISO19139MetadataDecoder
instance, configured for decoding the given ISO19115 extension. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeMetadata
(String aSourceName) Tells whether or not this decoder can likely decode the given source name.decodeMetadata
(String aSourcePath) Decodes an ISO 19139 data source.decodeObject
(String aSourcePath) Decodes an ISO 19139 data source.findAndDecodeMetadata
(String aSourceName) Searches metadata files for a given source name and decodes them as an ISO-19115 metadata object.Returns theorg.xml.sax.ext.EntityResolver2
that is used for creating input sources for XSD schemas.Returns theILcdInputStreamFactory
that is used for creating input streams.Returns thejavax.xml.stream.XMLInputFactory
that is used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.boolean
Returns if application schemas are cached.void
setEntityResolver
(EntityResolver2 aEntityResolver) Sets theorg.xml.sax.ext.EntityResolver2
to be used for creating input sources for XSD schemas.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets theILcdInputStreamFactory
to be used for creating input streams.void
setUseApplicationSchemaCache
(boolean aUseCache) Enables or disables application schema caching depending on the parameter value.void
setXMLInputFactory
(XMLInputFactory aXMLInputFactory) Sets thejavax.xml.stream.XMLInputFactory
to be used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.
-
Constructor Details
-
TLcdISO19139MetadataDecoder
public TLcdISO19139MetadataDecoder()Creates a newTLcdISO19139MetadataDecoder
instance. This decoder is configured for decoding any data type in the ISO19115 data model.- See Also:
-
TLcdISO19139MetadataDecoder
Creates a newTLcdISO19139MetadataDecoder
instance, configured for decoding the given ISO19115 extension. The initialized decoder also supports all data types in the ISO19115 data model.- Parameters:
aDataModel
- a data model representing an ISO191115 extension. The data model should be built from an XML schema using TLcdXMLDataModelBuilder, and should depend on the ISO19115 data model.- See Also:
-
-
Method Details
-
getInputStreamFactory
Returns theILcdInputStreamFactory
that is used for creating input streams.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the
ILcdInputStreamFactory
that is used for creating input streams.
-
setInputStreamFactory
Sets theILcdInputStreamFactory
to be used for creating input streams.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the input stream factory to be used by this model decoder.
-
getXMLInputFactory
Returns thejavax.xml.stream.XMLInputFactory
that is used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.- Returns:
- the
javax.xml.stream.XMLInputFactory
that is used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.
-
setXMLInputFactory
Sets thejavax.xml.stream.XMLInputFactory
to be used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.- Parameters:
aXMLInputFactory
- thejavax.xml.stream.XMLInputFactory
to be used by this decoder for creatingjavax.xml.stream.XMLStreamReader
instances.
-
getEntityResolver
Returns theorg.xml.sax.ext.EntityResolver2
that is used for creating input sources for XSD schemas. This entity resolver will only be used to resolve extension schemas that are not already configured on this decoder.- Returns:
- the entity resolver to be used for creating input sources for XSD schemas.
-
setEntityResolver
Sets the
org.xml.sax.ext.EntityResolver2
to be used for creating input sources for XSD schemas.When the entity resolver is unable to find a schema (i.e. the
resolveEntity
method returnsnull
), thegetInputStreamFactory()
is used to create an appropriate input stream for the given system id of the schema.- Parameters:
aEntityResolver
- the entity resolver to be used for creating input sources for XSD schemas.
-
isUseApplicationSchemaCache
public boolean isUseApplicationSchemaCache()Returns if application schemas are cached. When application schemas are cached, the decoder caches all applications schemas it encounters. When a certain schema is referenced during decoding, only if the schema is not found in the cache, it will be resolved. The default is
true
.Note that in case multiple application schemas use the same namespace URI, it is not possible to turn on application schema caching because the decoder will not be able to discern between the different schemas.
- Returns:
- if application schemas are cached
- Since:
- 2017.1
-
setUseApplicationSchemaCache
public void setUseApplicationSchemaCache(boolean aUseCache) Enables or disables application schema caching depending on the parameter value.- Parameters:
aUseCache
- if true, application schema caching is turned on. If false, caching is turned off.- Since:
- 2017.1
-
canDecodeMetadata
Tells whether or not this decoder can likely decode the given source name.- Specified by:
canDecodeMetadata
in interfaceILcdMetadataDecoder
- Parameters:
aSourceName
- the source name to decode metadata for- Returns:
- whether or not this decoder can likely decode the given source name
-
decodeMetadata
Decodes an ISO 19139 data source. The given data source points to a ISO 19139 XML file.Only use this method if the given data source contains a single metadata entity (that is, the root element of the XML is either
MD_Metadata
, or any other element of typegmd:MD_Metadata_Type
or a subtype hereof). For all other data sources, usedecodeObject(String)
.- Specified by:
decodeMetadata
in interfaceILcdMetadataDecoder
- Parameters:
aSourcePath
- the data source to be decoded; typically a file name or a URL.- Returns:
- a
TLcdISO19115Metadata
object representing the decoded metadata. - Throws:
IOException
- for any exceptions caused by IO problems or invalid data.- See Also:
-
findAndDecodeMetadata
public ILcdMetadataDecoder.MetadataWithSource findAndDecodeMetadata(String aSourceName) throws IOException Searches metadata files for a given source name and decodes them as an ISO-19115 metadata object. The given source name points to a data set, not to a dedicated metadata file. A return value ofnull
indicates that this decoder could not find dedicated metadata files for the given source name.This decoder will search for an ISO 19139 data file having the same name as the source name of the data set, but with an '.xml' extension. If the data set itself already has the '.xml' extension, no search is performed and
null
is returned.Only use this method if the accompanied metadata file contains a single metadata entity (that is, the root element of the XML is either
MD_Metadata
, or any other element of typegmd:MD_Metadata_Type
or a subtype hereof).- Specified by:
findAndDecodeMetadata
in interfaceILcdMetadataDecoder
- Parameters:
aSourceName
- the data source to be decoded; typically a file name or a URL.- Returns:
- the decoded
TLcdISO19115Metadata
and the location of the additional metadata file(s) from which they * were decoded. - Throws:
IOException
- for any exceptions caused by IO problems or invalid data.- Since:
- 2022.1
- See Also:
-
decodeObject
Decodes an ISO 19139 data source. The returned object is anILcdDataObject
whose instance class corresponds to the XML root element in the data source. This instance class may be any class in thecom.luciad.format.metadata.model
package or its subpackages. Some typical examples:- An <MD_Metadata> element is decoded to a
TLcdISO19115Metadata
instance - An <DS_Dataset> is decoded to a
TLcdISO19115DataSet
instance - An <DS_Series> is decoded to a
TLcdISO19115Series
instance
- Parameters:
aSourcePath
- the data source to be decoded; typically a file name or a URL.- Returns:
- an
ILcdDataObject
representing the decoded metadata. - Throws:
IOException
- for any exceptions caused by IO problems or invalid data.
- An <MD_Metadata> element is decoded to a
-