@LcdService(service=ILcdMetadataDecoder.class, priority=20000) public class TLcdISO19139MetadataDecoder extends Object implements 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.
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)
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.
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 );
TLcdISO19115Metadata
,
TLcdISO19139MetadataEncoder
,
com.luciad.format.metadata.model
ILcdMetadataDecoder.MetadataWithSource
Constructor and Description |
---|
TLcdISO19139MetadataDecoder()
Creates a new
TLcdISO19139MetadataDecoder instance. |
TLcdISO19139MetadataDecoder(TLcdDataModel aDataModel)
Creates a new
TLcdISO19139MetadataDecoder instance, configured for decoding the
given ISO19115 extension. |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeMetadata(String aSourceName)
Tells whether or not this decoder can likely decode the given source name.
|
TLcdISO19115Metadata |
decodeMetadata(String aSourcePath)
Decodes an ISO 19139 data source.
|
ILcdDataObject |
decodeObject(String aSourcePath)
Decodes an ISO 19139 data source.
|
ILcdMetadataDecoder.MetadataWithSource |
findAndDecodeMetadata(String aSourceName)
Searches metadata files for a given source name and decodes them as an ISO-19115 metadata object.
|
EntityResolver2 |
getEntityResolver()
Returns the
org.xml.sax.ext.EntityResolver2 that is used for creating input sources for
XSD schemas. |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the
ILcdInputStreamFactory that is used for creating input streams. |
XMLInputFactory |
getXMLInputFactory()
Returns the
javax.xml.stream.XMLInputFactory that is used by this decoder for creating
javax.xml.stream.XMLStreamReader instances. |
boolean |
isUseApplicationSchemaCache()
Returns if application schemas are cached.
|
void |
setEntityResolver(EntityResolver2 aEntityResolver)
Sets the
org.xml.sax.ext.EntityResolver2 to be used for creating input sources for
XSD schemas. |
void |
setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
Sets the
ILcdInputStreamFactory 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 the
javax.xml.stream.XMLInputFactory to be used by this decoder for creating
javax.xml.stream.XMLStreamReader instances. |
public TLcdISO19139MetadataDecoder()
TLcdISO19139MetadataDecoder
instance. This decoder is configured
for decoding any data type in the ISO19115 data model.com.luciad.format.metadata.model
public TLcdISO19139MetadataDecoder(TLcdDataModel aDataModel)
TLcdISO19139MetadataDecoder
instance, configured for decoding the
given ISO19115 extension.
The initialized decoder also supports all data types in the ISO19115 data model.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.com.luciad.format.metadata.model
public ILcdInputStreamFactory getInputStreamFactory()
ILcdInputStreamFactory
that is used for creating input streams.getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
ILcdInputStreamFactory
that is used for creating input streams.public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
ILcdInputStreamFactory
to be used for creating input streams.setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
aInputStreamFactory
- the input stream factory to be used by this model decoder.public XMLInputFactory getXMLInputFactory()
javax.xml.stream.XMLInputFactory
that is used by this decoder for creating
javax.xml.stream.XMLStreamReader
instances.javax.xml.stream.XMLInputFactory
that is used by this decoder for creating
javax.xml.stream.XMLStreamReader
instances.public void setXMLInputFactory(XMLInputFactory aXMLInputFactory)
javax.xml.stream.XMLInputFactory
to be used by this decoder for creating
javax.xml.stream.XMLStreamReader
instances.aXMLInputFactory
- the javax.xml.stream.XMLInputFactory
to be used by this decoder
for creating javax.xml.stream.XMLStreamReader
instances.public EntityResolver2 getEntityResolver()
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.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.
aEntityResolver
- the entity resolver to be used for creating input sources for XSD schemas.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.
public void setUseApplicationSchemaCache(boolean aUseCache)
aUseCache
- if true, application schema caching is turned on. If false,
caching is turned off.public boolean canDecodeMetadata(String aSourceName)
canDecodeMetadata
in interface ILcdMetadataDecoder
aSourceName
- the source name to decode metadata forpublic TLcdISO19115Metadata decodeMetadata(String aSourcePath) throws IOException
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)
.
decodeMetadata
in interface ILcdMetadataDecoder
aSourcePath
- the data source to be decoded; typically a file name or a URL.TLcdISO19115Metadata
object representing the decoded metadata.IOException
- for any exceptions caused by IO problems or invalid data.findAndDecodeMetadata(String)
,
decodeObject(String)
public ILcdMetadataDecoder.MetadataWithSource findAndDecodeMetadata(String aSourceName) throws IOException
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).
findAndDecodeMetadata
in interface ILcdMetadataDecoder
aSourceName
- the data source to be decoded; typically a file name or a URL.TLcdISO19115Metadata
and the location of the additional metadata file(s) from which they
* were decoded.IOException
- for any exceptions caused by IO problems or invalid data.decodeObject(String)
public ILcdDataObject decodeObject(String aSourcePath) throws IOException
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:
TLcdISO19115Metadata
instanceTLcdISO19115DataSet
instanceTLcdISO19115Series
instanceaSourcePath
- the data source to be decoded; typically a file name or a URL.ILcdDataObject
representing the decoded metadata.IOException
- for any exceptions caused by IO problems or invalid data.