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 ILcdEarthAssetCodecs 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
ConstructorsConstructorDescriptionConstructs a newTLcdEarthAssetModelCodecwith the default model reference encoder/decoder, input/output stream factories and asset codecs. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAssetCodec(ILcdEarthAssetCodec aCodec) Adds an asset codec to thisTLcdEarthAssetModelCodec.booleancanDecodeSource(String aSourceName) Checks whether this model decoder can decode the specified data source.booleanReturns whether this encoder can export the specified model to the specified destination.booleanReturns whether this model encoder can save the specified model to the location it originally came from.Decodes an asset model from the given file.voidExports 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.voidRemoves all asset codecs from thisTLcdEarthAssetModelCodec.booleanremoveAssetCodec(ILcdEarthAssetCodec aCodec) Removes an asset codec from thisTLcdEarthAssetModelCodecif it is present.voidSaves the model to the location where it originally came from.voidsetInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory to be used when decoding asset models.voidsetModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder) Sets the model reference decodervoidsetModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder) Sets the model reference encodervoidsetOutputStreamFactory(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, waitMethods inherited from interface com.luciad.model.ILcdModelDecoder
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
-
Constructor Details
-
TLcdEarthAssetModelCodec
public TLcdEarthAssetModelCodec()Constructs a newTLcdEarthAssetModelCodecwith the default model reference encoder/decoder, input/output stream factories and asset codecs.
-
-
Method Details
-
getDisplayName
Description copied from interface:ILcdModelDecoderReturns a short, displayable name for the format that is decoded by thisILcdModelDecoder.- Specified by:
getDisplayNamein interfaceILcdModelDecoder- Specified by:
getDisplayNamein 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:ILcdModelDecoderChecks whether this model decoder can decode the specified data source. It is acceptable for this method to returntruefor a source name whiledecodethrows 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:
canDecodeSourcein interfaceILcdModelDecoder- Parameters:
aSourceName- the data source to be verified; typically a file name or a URL.- Returns:
trueif this decoder can likely decode the data specified by the source name,falseotherwise.- See Also:
-
canSave
Description copied from interface:ILcdModelEncoderReturns 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:
canSavein interfaceILcdModelEncoder- Parameters:
aModel- the model to be verified.- Returns:
trueif this encoder can save the model in the location where it originally came from,falseotherwise.- See Also:
-
save
Description copied from interface:ILcdModelEncoderSaves the model to the location where it originally came from.- Specified by:
savein 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:ILcdModelEncoderReturns 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:
canExportin interfaceILcdModelEncoder- Parameters:
aModel- the model to be verified.aDestination- the location where the model should be exported to.- Returns:
trueif this encoder can export the specified model to the specified location,falseotherwise.- 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:ILcdModelEncoderExports the specified model to the specified destination.- Specified by:
exportin 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:
decodein 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 thisTLcdEarthAssetModelCodecif 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
-