Class TLcdISO19139MetadataDecoder

java.lang.Object
com.luciad.format.metadata.xml.TLcdISO19139MetadataDecoder
All Implemented Interfaces:
ILcdMetadataDecoder, ILcdInputStreamFactoryCapable

@LcdService(service=ILcdMetadataDecoder.class, priority=20000) public class TLcdISO19139MetadataDecoder extends Object implements ILcdMetadataDecoder, ILcdInputStreamFactoryCapable
An ISO 19139 data source decoder.

ISO 19139 defines the XML encoding for the metadata model ISO 19115. An implementation and domain model for ISO 19115 is available in the 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:

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 the xsi: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:
  • Constructor Details

    • TLcdISO19139MetadataDecoder

      public TLcdISO19139MetadataDecoder()
      Creates a new TLcdISO19139MetadataDecoder instance. This decoder is configured for decoding any data type in the ISO19115 data model.
      See Also:
    • TLcdISO19139MetadataDecoder

      public TLcdISO19139MetadataDecoder(TLcdDataModel aDataModel)
      Creates a new TLcdISO19139MetadataDecoder 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

      public ILcdInputStreamFactory getInputStreamFactory()
      Returns the ILcdInputStreamFactory that is used for creating input streams.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the ILcdInputStreamFactory that is used for creating input streams.
    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the ILcdInputStreamFactory to be used for creating input streams.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used by this model decoder.
    • getXMLInputFactory

      public XMLInputFactory getXMLInputFactory()
      Returns the javax.xml.stream.XMLInputFactory that is used by this decoder for creating javax.xml.stream.XMLStreamReader instances.
      Returns:
      the javax.xml.stream.XMLInputFactory that is used by this decoder for creating javax.xml.stream.XMLStreamReader instances.
    • setXMLInputFactory

      public void setXMLInputFactory(XMLInputFactory aXMLInputFactory)
      Sets the javax.xml.stream.XMLInputFactory to be used by this decoder for creating javax.xml.stream.XMLStreamReader instances.
      Parameters:
      aXMLInputFactory - the javax.xml.stream.XMLInputFactory to be used by this decoder for creating javax.xml.stream.XMLStreamReader instances.
    • getEntityResolver

      public EntityResolver2 getEntityResolver()
      Returns the org.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

      public void setEntityResolver(EntityResolver2 aEntityResolver)

      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 returns null), the getInputStreamFactory() 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

      public boolean canDecodeMetadata(String aSourceName)
      Tells whether or not this decoder can likely decode the given source name.
      Specified by:
      canDecodeMetadata in interface ILcdMetadataDecoder
      Parameters:
      aSourceName - the source name to decode metadata for
      Returns:
      whether or not this decoder can likely decode the given source name
    • decodeMetadata

      public TLcdISO19115Metadata decodeMetadata(String aSourcePath) throws IOException
      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, use decodeObject(String).

      Specified by:
      decodeMetadata in interface ILcdMetadataDecoder
      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 of null 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 interface ILcdMetadataDecoder
      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

      public ILcdDataObject decodeObject(String aSourcePath) throws IOException
      Decodes an ISO 19139 data source. The returned object is an ILcdDataObject whose instance class corresponds to the XML root element in the data source. This instance class may be any class in the com.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.