public class TLcdGMLApplicationModelDecoder extends Object implements ILcdModelDecoder
ILcdDataObject
-enabled models.
The important difference with the other GML decoders (such as e.g. TLcdGML32ModelDecoder
) is that the
elements of the resulting model are not GML abstract features.
They are the result of applying the inverse of the specified GML transformation
on the abstract features contained in the source document.
The transformation does not specify the model implementation class and/or model descriptor of the decoded models.
This is configured separately
.
TLcdGMLApplicationModelEncoder
Constructor and Description |
---|
TLcdGMLApplicationModelDecoder(TLcdGMLTransformer aTransformer)
Constructs a new instance based on the given
TLcdGMLTransformer
and a new TLcdXMLSchemaBasedDecoder . |
TLcdGMLApplicationModelDecoder(TLcdXMLSchemaBasedDecoder aDecoder,
TLcdGMLTransformer aTransformer)
Constructs a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
ILcdModel |
decode(Source aSource,
ILcdXMLDocumentContext aDocumentContext)
Decodes the given source, transforms the GML features that are contained within
it and adds these to the returned model.
|
ILcdModel |
decode(String aSourceName)
Creates a new model from the given data source.
|
TLcdXMLSchemaBasedDecoder |
getDecoder()
Returns the
TLcdXMLSchemaBasedDecoder that this object uses
to decode the GML documents. |
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdModelFactory |
getModelFactory()
Returns the model factory that is used to create the new model that
is returned as the decoding result.
|
ILcdModelReferenceParser |
getModelReferenceParser()
Returns the model reference parser used by the decoder to turn srsNames
into
ILcdModelReference objects. |
void |
setModelFactory(ILcdModelFactory aModelFactory)
Sets the model factory that should be used to create the models that are
returned by this decoder.
|
void |
setModelReferenceParser(ILcdModelReferenceParser aModelReferenceParser)
Sets the model reference parser.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdGMLApplicationModelDecoder(TLcdGMLTransformer aTransformer)
TLcdGMLTransformer
and a new TLcdXMLSchemaBasedDecoder
.aTransformer
- the transformer to use to transform the decoded GML
objectspublic TLcdGMLApplicationModelDecoder(TLcdXMLSchemaBasedDecoder aDecoder, TLcdGMLTransformer aTransformer)
TLcdXMLSchemaBasedDecoder
is
used to decode GML documents. The given TLcdGMLTransformer
is used
to transform the GML object back into the source data model. Note that the
transformer's target data model is expected to be dependent on GML; as such
the inverse transformations of the transformer will be used to create
instances of the source data model.aDecoder
- the decoder to use for decoding the GML documentsaTransformer
- the transformer to use to transform the GML objects into the source data modelpublic String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface 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.
This implementation accepts the default extensions of the used GML data model (see the correspondingGML32
, GML31
,
and GML2
decoders).canDecodeSource
in interface ILcdModelDecoder
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
ILcdModelDecoder
decode
in interface ILcdModelDecoder
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 ILcdModel decode(Source aSource, ILcdXMLDocumentContext aDocumentContext) throws IOException
aSource
- a source containing a GML feature collectionaDocumentContext
- the document context to use during decodingIOException
public TLcdXMLSchemaBasedDecoder getDecoder()
TLcdXMLSchemaBasedDecoder
that this object uses
to decode the GML documents.public ILcdModelReferenceParser getModelReferenceParser()
ILcdModelReference
objects.public void setModelReferenceParser(ILcdModelReferenceParser aModelReferenceParser)
aModelReferenceParser
- the model reference parser to use during decodingpublic ILcdModelFactory getModelFactory()
public void setModelFactory(ILcdModelFactory aModelFactory)
aModelFactory
- the model factory to use for creating models