public class TLcdGMLApplicationModelEncoder extends Object implements ILcdModelEncoder
ILcdDataObject
-enabled ILcdModel
instances to GML documents.
This is similar to the export functionality provided by the GML encoders
(such as e.g. TLcdGML32ModelEncoder
), but it provides more fine-grained control of the
used transformation
.
This class is typically combined with TLcdGMLApplicationModelDecoder
, which allows decoding GML documents
back into the original data model.
The following snippet encodes a model to GML 3.2:
ILcdModel myModel = ...;
TLcdDataModel myDataModel = ...;
TLcdGMLTransformer transformer = new TLcdGMLTransformerBuilder(myDataModel)
.gmlDataModel(TLcdGML32DataTypes.getDataModel())
.build();
TLcdGMLApplicationModelEncoder encoder = new TLcdGMLApplicationModelEncoder(transformer);
encoder.export(myModel, "path/to/destinationFile.gml32");
The same transformer can be passed to TLcdGMLApplicationModelDecoder
to decode the file again with the original
data model.TLcdGMLApplicationModelDecoder
,
Serialized FormConstructor and Description |
---|
TLcdGMLApplicationModelEncoder(TLcdGMLTransformer aTransformer)
Constructs a new instance based on the given
TLcdGMLTransformer
and a new TLcdXMLSchemaBasedEncoder . |
TLcdGMLApplicationModelEncoder(TLcdXMLSchemaBasedEncoder aEncoder,
TLcdGMLTransformer aTransformer)
Constructs a new instance.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canExport(ILcdModel aModel,
String aDestinationName)
Returns whether this encoder can export the specified model to the specified destination.
|
boolean |
canSave(ILcdModel aModel)
Returns whether this model encoder can save the specified model to the location it originally came from.
|
void |
export(ILcdModel aModel,
Result aDestination,
ILcdXMLDocumentContext context)
Exports the given model to given destination.
|
void |
export(ILcdModel aModel,
String aDestinationName)
Exports the specified model to the specified destination.
|
String |
getDisplayName()
Returns a short, displayable name for the format this
ILcdModelEncoder encodes to. |
TLcdXMLSchemaBasedEncoder |
getEncoder()
Returns the encoder used by this object.
|
ILcdModelReferenceFormatter |
getModelReferenceFormatter()
Returns the model reference formatter that is used to format
ILcdModelReference
instances when encoding an srsName. |
void |
save(ILcdModel aModel)
Saves the model to the location where it originally came from.
|
void |
setModelReferenceFormatter(ILcdModelReferenceFormatter aModelReferenceFormatter)
Sets the formatter that is used to format
ILcdModelReference instances
when encoding an srsName. |
public TLcdGMLApplicationModelEncoder(TLcdGMLTransformer aTransformer)
TLcdGMLTransformer
and a new TLcdXMLSchemaBasedEncoder
.aTransformer
- the TLcdGMLTransformer
to use to transform
model elements into GMLpublic TLcdGMLApplicationModelEncoder(TLcdXMLSchemaBasedEncoder aEncoder, TLcdGMLTransformer aTransformer)
TLcdXMLSchemaBasedEncoder
is
used to generate the GML documents. The given TLcdGMLTransformer
is used
to transform the source model elements into GMLaEncoder
- the encoder to use to generate GML documentsaTransformer
- the transformer to use to transform the source objects into GMLpublic String getDisplayName()
ILcdModelEncoder
ILcdModelEncoder
encodes to.getDisplayName
in interface ILcdModelEncoder
ILcdModelEncoder
.public boolean canSave(ILcdModel aModel)
ILcdModelEncoder
canSave
in interface ILcdModelEncoder
aModel
- the model to be verified.true
if this encoder can save the model in the location where it originally came from,
false
otherwise.ILcdModelEncoder.save(com.luciad.model.ILcdModel)
public void save(ILcdModel aModel) throws IllegalArgumentException, IOException
ILcdModelEncoder
save
in interface ILcdModelEncoder
aModel
- the model to be saved.IllegalArgumentException
- if the model cannot be saved by this encoder (!canSave(aModel)
).IOException
- if an I/O error occurs during encoding.public boolean canExport(ILcdModel aModel, String aDestinationName)
ILcdModelEncoder
canExport
in interface ILcdModelEncoder
aModel
- the model to be verified.aDestinationName
- the location where the model should be exported to.true
if this encoder can export the specified model to the
specified location, false
otherwise.ILcdModelEncoder.export(com.luciad.model.ILcdModel, java.lang.String)
public void export(ILcdModel aModel, String aDestinationName) throws IllegalArgumentException, IOException
ILcdModelEncoder
export
in interface ILcdModelEncoder
aModel
- the model to be exported.aDestinationName
- the location where the model should be saved. Typically, this is a name for the output
file, but it can also point to a file containing the required properties to create a set
of data files.IllegalArgumentException
- if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)
).IOException
- if an I/O error occurs during encoding.public void export(ILcdModel aModel, Result aDestination, ILcdXMLDocumentContext context) throws IOException
aModel
- the model to exportaDestination
- the destination to write the XML tocontext
- the XML contextIOException
public ILcdModelReferenceFormatter getModelReferenceFormatter()
ILcdModelReference
instances when encoding an srsName.public void setModelReferenceFormatter(ILcdModelReferenceFormatter aModelReferenceFormatter)
ILcdModelReference
instances
when encoding an srsName.aModelReferenceFormatter
- the model reference formatter for this encoderpublic TLcdXMLSchemaBasedEncoder getEncoder()