Class TLcdGMLApplicationModelEncoder
java.lang.Object
com.luciad.format.gmlcommon.transformation.TLcdGMLApplicationModelEncoder
- All Implemented Interfaces:
ILcdModelEncoder
,Serializable
Encodes
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.- Since:
- 11.0
- See Also:
-
Constructor Summary
ConstructorDescriptionTLcdGMLApplicationModelEncoder
(TLcdGMLTransformer aTransformer) Constructs a new instance based on the givenTLcdGMLTransformer
and a newTLcdXMLSchemaBasedEncoder
.TLcdGMLApplicationModelEncoder
(TLcdXMLSchemaBasedEncoder aEncoder, TLcdGMLTransformer aTransformer) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns whether this encoder can export the specified model to the specified destination.boolean
Returns whether this model encoder can save the specified model to the location it originally came from.void
Exports the specified model to the specified destination.void
export
(ILcdModel aModel, Result aDestination, ILcdXMLDocumentContext context) Exports the given model to given destination.Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.Returns the encoder used by this object.Returns the model reference formatter that is used to formatILcdModelReference
instances when encoding an srsName.void
Saves the model to the location where it originally came from.void
setModelReferenceFormatter
(ILcdModelReferenceFormatter aModelReferenceFormatter) Sets the formatter that is used to formatILcdModelReference
instances when encoding an srsName.
-
Constructor Details
-
TLcdGMLApplicationModelEncoder
Constructs a new instance based on the givenTLcdGMLTransformer
and a newTLcdXMLSchemaBasedEncoder
.- Parameters:
aTransformer
- theTLcdGMLTransformer
to use to transform model elements into GML
-
TLcdGMLApplicationModelEncoder
public TLcdGMLApplicationModelEncoder(TLcdXMLSchemaBasedEncoder aEncoder, TLcdGMLTransformer aTransformer) Constructs a new instance. The givenTLcdXMLSchemaBasedEncoder
is used to generate the GML documents. The givenTLcdGMLTransformer
is used to transform the source model elements into GML- Parameters:
aEncoder
- the encoder to use to generate GML documentsaTransformer
- the transformer to use to transform the source objects into GML
-
-
Method Details
-
getDisplayName
Description copied from interface:ILcdModelEncoder
Returns a short, displayable name for the format thisILcdModelEncoder
encodes to.- Specified by:
getDisplayName
in interfaceILcdModelEncoder
- Returns:
- the displayable name of this
ILcdModelEncoder
.
-
canSave
Description copied from interface:ILcdModelEncoder
Returns whether this model encoder can save the specified model to the location it originally came from. Often this will only be a simple test, for example checking the type of the model's model descriptor.- Specified by:
canSave
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be verified.- Returns:
true
if this encoder can save the model in the location where it originally came from,false
otherwise.- See Also:
-
save
Description copied from interface:ILcdModelEncoder
Saves the model to the location where it originally came from.- Specified by:
save
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be saved.- Throws:
IllegalArgumentException
- if the model cannot be saved by this encoder (!canSave(aModel)
).IOException
- if an I/O error occurs during encoding.
-
canExport
Description copied from interface:ILcdModelEncoder
Returns whether this encoder can export the specified model to the specified destination. This method will typically check whether the contents of the specified model are compatible with the format this encoder is written for.- Specified by:
canExport
in interfaceILcdModelEncoder
- Parameters:
aModel
- the model to be verified.aDestinationName
- the location where the model should be exported to.- Returns:
true
if this encoder can export the specified model to the specified location,false
otherwise.- See Also:
-
export
public void export(ILcdModel aModel, String aDestinationName) throws IllegalArgumentException, IOException Description copied from interface:ILcdModelEncoder
Exports the specified model to the specified destination.- Specified by:
export
in interfaceILcdModelEncoder
- Parameters:
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.- Throws:
IllegalArgumentException
- if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)
).IOException
- if an I/O error occurs during encoding.
-
export
public void export(ILcdModel aModel, Result aDestination, ILcdXMLDocumentContext context) throws IOException Exports the given model to given destination. The document context is used during the XML encoding.- Parameters:
aModel
- the model to exportaDestination
- the destination to write the XML tocontext
- the XML context- Throws:
IOException
-
getModelReferenceFormatter
Returns the model reference formatter that is used to formatILcdModelReference
instances when encoding an srsName.- Returns:
- the model reference formatter of this encoder
-
setModelReferenceFormatter
Sets the formatter that is used to formatILcdModelReference
instances when encoding an srsName.- Parameters:
aModelReferenceFormatter
- the model reference formatter for this encoder
-
getEncoder
Returns the encoder used by this object.- Returns:
- the encoder used by this object
-