@LcdService(service=ILcdModelDecoder.class, priority=20000) public class TLcdNVGModelDecoder extends ALcdXMLModelDecoder
File | Required | Entry point | Description |
---|---|---|---|
*.xml, *.nvg | x | x |
NVG XML file |
ILcdInputStreamFactory
of this decoder.ILcd2DBoundsIndexedModel
.TLcdNVG15Model
TLcdNVG20FilteredModel
.
This model wrapper provides a time-filtered view on the original data
,
which extends TLcdNVG20Model
TLcdNVGModelDescriptor
.TLcdNVG15ModelDescriptor
TLcdNVG20ModelDescriptor
WGS 84 georeference
ILcdShape
and ILcdDataObject
text
,
groups
and composites
,
or symbolized content
text
,
groups
and anchors
,
or data objects
// decode the model
TLcdNVGModelDecoder decoder = new TLcdNVGModelDecoder();
TLcdNVG20FilteredModel model = (TLcdNVG20FilteredModel)decoder.decode("nvg20file.xml");
// update the model to only expose elements of the given date
model.setDate(aDate);
// access all model elements, regardless of the date
TLcdNVG20Model modelWithAllElements = model.getUnfilteredModel()
Constructor and Description |
---|
TLcdNVGModelDecoder()
Creates a new
TLcdNVGModelDecoder , ready to use. |
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
EntityResolver2 |
getEntityResolver()
Returns the
org.xml.sax.ext.EntityResolver2 that is used for creating input sources for
XSD schemas. |
ILcdInputStreamFactory |
getInputStreamFactory()
Get the input stream factory of this NVG model decoder.
|
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)
Set the input stream factory to this NVG model decoder.
|
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. |
decode
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdNVGModelDecoder()
TLcdNVGModelDecoder
, ready to use.public String getDisplayName()
ILcdModelDecoder
.ILcdModelDecoder
.public boolean canDecodeSource(String aSourceName)
true
for a source name while decode
throws an exception for that same source name.
For performance reasons, we strongly recommend that this will only be a simple test. For example: check the file extension of a file, but not that the file exists or contains expected content.
aSourceName
- the data source to be verified; typically a file name or a URL.true
if this decoder can likely decode the data specified by the source name, false
otherwise.ILcdModelDecoder.decode(String)
,
ILcdModelDecoder.decodeModelMetadata(String)
public ILcdModel decode(String aSourceName) throws IOException
aSourceName
- the data source to be decoded; typically a file name or a URL.null
is allowed, implementors are advised to throw an error instead.IOException
- for any exceptions caused by IO problems or invalid data. Since decoding invalid data almost
always results in RunTimeExceptions (NullPointerException, IndexOutOfBoundsException,
IllegalArgumentException, ...) on unexpected places, implementations are advised to catch
RuntimeExceptions in their decode() method, and wrap them into an IOException, as illustrated
in the code snippet below.
public ILcdModel decode( String aSourceName ) throws IOException {
try (InputStream input = fInputStreamFactory.createInputStream(aSourceName)) {
// Perform decoding ...
} catch (RuntimeException e) {
throw new IOException(e);
}
}
InterruptedIOException
- When the thread on which this method is called is interrupted: it is recommended to stop the decoding
and throw an InterruptedIOException
.
This same exception can also be used if the decoder shows UI to the user, and the user cancels the decoding
through the UI.ILcdModelDecoder.canDecodeSource(String)
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
setInputStreamFactory
in interface ILcdInputStreamFactoryCapable
setInputStreamFactory
in class ALcdXMLModelDecoder
aInputStreamFactory
- The input stream factory to set to this decoder.ALcdXMLModelDecoder.getInputStreamFactory()
public XMLInputFactory getXMLInputFactory()
ALcdXMLModelDecoder
javax.xml.stream.XMLInputFactory
that is used by this decoder for creating
javax.xml.stream.XMLStreamReader
instances.getXMLInputFactory
in class ALcdXMLModelDecoder
javax.xml.stream.XMLInputFactory
that is used by this decoder for creating
javax.xml.stream.XMLStreamReader
instances.public void setXMLInputFactory(XMLInputFactory aXMLInputFactory)
ALcdXMLModelDecoder
javax.xml.stream.XMLInputFactory
to be used by this decoder for creating
javax.xml.stream.XMLStreamReader
instances.setXMLInputFactory
in class ALcdXMLModelDecoder
aXMLInputFactory
- the javax.xml.stream.XMLInputFactory
to be used by this decoder
for creating javax.xml.stream.XMLStreamReader
instances.public EntityResolver2 getEntityResolver()
ALcdXMLModelDecoder
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.getEntityResolver
in class ALcdXMLModelDecoder
public void setEntityResolver(EntityResolver2 aEntityResolver)
ALcdXMLModelDecoder
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 ALcdXMLModelDecoder.getInputStreamFactory()
is used to
create an appropriate input stream for the given system id of the schema.
setEntityResolver
in class ALcdXMLModelDecoder
aEntityResolver
- the entity resolver to be used for creating input sources for XSD schemas.public boolean isUseApplicationSchemaCache()
ALcdXMLModelDecoder
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 not to cache.
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.
isUseApplicationSchemaCache
in class ALcdXMLModelDecoder
public void setUseApplicationSchemaCache(boolean aUseCache)
ALcdXMLModelDecoder
setUseApplicationSchemaCache
in class ALcdXMLModelDecoder
aUseCache
- if true, application schema caching is turned on. If false,
caching is turned off.public ILcdInputStreamFactory getInputStreamFactory()
getInputStreamFactory
in interface ILcdInputStreamFactoryCapable
getInputStreamFactory
in class ALcdXMLModelDecoder
ALcdXMLModelDecoder.setInputStreamFactory(com.luciad.io.ILcdInputStreamFactory)