Package com.luciad.earth.metadata.format
Class TLcdEarthAssetModelCodec
java.lang.Object
com.luciad.earth.metadata.format.TLcdEarthAssetModelCodec
- All Implemented Interfaces:
ILcdModelDecoder
,ILcdModelEncoder
,Serializable
Encodes and decodes models containing
ILcdEarthAsset
objects.
Metadata objects are encoded to an XML format in which each ILcdEarthAsset
is
represented by a list of key/value pairs. These lists are generated by ILcdEarthAssetCodec
s which can be registered with this class, and are represented in memory as
Properties
objects. The required asset codecs must be registered before this
class can be used.- Since:
- 8.2
- See Also:
-
Constructor Summary
ConstructorDescriptionConstructs a newTLcdEarthAssetModelCodec
with the default model reference encoder/decoder, input/output stream factories and asset codecs. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAssetCodec
(ILcdEarthAssetCodec aCodec) Adds an asset codec to thisTLcdEarthAssetModelCodec
.boolean
canDecodeSource
(String aSourceName) Checks whether this model decoder can decode the specified data source.boolean
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.Decodes an asset model from the given file.void
Exports the specified model to the specified destination.Returns the current collection of asset codecs.Returns the default model reference.Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.Returns the input stream factory to be used when decoding asset models.Returns the model reference decoder.Returns the model reference encoder.Returns the output stream factory to be used when encoding asset models.void
Removes all asset codecs from thisTLcdEarthAssetModelCodec
.boolean
removeAssetCodec
(ILcdEarthAssetCodec aCodec) Removes an asset codec from thisTLcdEarthAssetModelCodec
if it is present.void
Saves the model to the location where it originally came from.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory to be used when decoding asset models.void
setModelReferenceDecoder
(ILcdModelReferenceDecoder aModelReferenceDecoder) Sets the model reference decodervoid
setModelReferenceEncoder
(ILcdModelReferenceEncoder aModelReferenceEncoder) Sets the model reference encodervoid
setOutputStreamFactory
(ILcdOutputStreamFactory aOutputStreamFactory) Sets the output stream factory to be used when encoding asset models.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Constructor Details
-
TLcdEarthAssetModelCodec
public TLcdEarthAssetModelCodec()Constructs a newTLcdEarthAssetModelCodec
with the default model reference encoder/decoder, input/output stream factories and asset codecs.
-
-
Method Details
-
getDisplayName
Description copied from interface:ILcdModelDecoder
Returns a short, displayable name for the format that is decoded by thisILcdModelDecoder
.- Specified by:
getDisplayName
in interfaceILcdModelDecoder
- Specified by:
getDisplayName
in interfaceILcdModelEncoder
- Returns:
- the displayable name of this
ILcdModelDecoder
.
-
getDefaultModelReference
Returns the default model reference.- Returns:
- the default model reference.
-
getModelReferenceDecoder
Returns the model reference decoder.- Returns:
- the model reference decoder.
-
setModelReferenceDecoder
Sets the model reference decoder- Parameters:
aModelReferenceDecoder
- the model reference decoder.
-
getModelReferenceEncoder
Returns the model reference encoder.- Returns:
- the model reference encoder.
-
setModelReferenceEncoder
Sets the model reference encoder- Parameters:
aModelReferenceEncoder
- the model reference encoder
-
canDecodeSource
Description copied from interface:ILcdModelDecoder
Checks whether this model decoder can decode the specified data source. It is acceptable for this method to returntrue
for a source name whiledecode
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.
- Specified by:
canDecodeSource
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the data source to be verified; typically a file name or a URL.- Returns:
true
if this decoder can likely decode the data specified by the source name,false
otherwise.- See Also:
-
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.aDestination
- 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:
-
getOutputStreamFactory
Returns the output stream factory to be used when encoding asset models.- Returns:
- the output stream factory to be used when encoding asset models
-
setOutputStreamFactory
Sets the output stream factory to be used when encoding asset models. The default value is aTLcdFileOutputStreamFactory
. The output stream factory must not be null.- Parameters:
aOutputStreamFactory
- an output stream factory
-
getInputStreamFactory
Returns the input stream factory to be used when decoding asset models.- Returns:
- the input stream factory to be used when decoding asset models
-
setInputStreamFactory
Sets the input stream factory to be used when decoding asset models. The default value is aTLcdInputStreamFactory
. The input stream factory must not be null.- Parameters:
aInputStreamFactory
- an input stream factory
-
export
public void export(ILcdModel aModel, String aDestination) 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.aDestination
- 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.
-
decode
Decodes an asset model from the given file.- Specified by:
decode
in interfaceILcdModelDecoder
- Parameters:
aSourceName
- the name of the file to be decoded- Returns:
- a new asset model
- Throws:
IOException
- if the file cannot be decoded- See Also:
-
addAssetCodec
Adds an asset codec to thisTLcdEarthAssetModelCodec
. The newly added codec will have precedence over all previously added codecs.- Parameters:
aCodec
- the codec to be registered
-
removeAssetCodec
Removes an asset codec from thisTLcdEarthAssetModelCodec
if it is present.- Parameters:
aCodec
- the codec to be removed- Returns:
- true if a codec was removed, false otherwise
-
removeAllAssetCodecs
public void removeAllAssetCodecs()Removes all asset codecs from thisTLcdEarthAssetModelCodec
. -
getAssetCodecs
Returns the current collection of asset codecs.- Returns:
- the current collection of asset codecs
-