public class TLcdEarthAssetModelCodec extends Object implements ILcdModelDecoder, ILcdModelEncoder
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.Constructor and Description |
---|
TLcdEarthAssetModelCodec()
Constructs a new
TLcdEarthAssetModelCodec with the default model reference
encoder/decoder, input/output stream factories and asset codecs. |
Modifier and Type | Method and Description |
---|---|
void |
addAssetCodec(ILcdEarthAssetCodec aCodec)
Adds an asset codec to this
TLcdEarthAssetModelCodec . |
boolean |
canDecodeSource(String aSourceName)
Checks whether this model decoder can decode the specified data source.
|
boolean |
canExport(ILcdModel aModel,
String aDestination)
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.
|
ILcdModel |
decode(String aSourceName)
Decodes an asset model from the given file.
|
void |
export(ILcdModel aModel,
String aDestination)
Exports the specified model to the specified destination.
|
Collection<ILcdEarthAssetCodec> |
getAssetCodecs()
Returns the current collection of asset codecs.
|
ILcdModelReference |
getDefaultModelReference()
Returns the default model reference.
|
String |
getDisplayName()
Returns a short, displayable name for the format that is decoded by this
ILcdModelDecoder . |
ILcdInputStreamFactory |
getInputStreamFactory()
Returns the input stream factory to be used when decoding asset models.
|
ILcdModelReferenceDecoder |
getModelReferenceDecoder()
Returns the model reference decoder.
|
ILcdModelReferenceEncoder |
getModelReferenceEncoder()
Returns the model reference encoder.
|
ILcdOutputStreamFactory |
getOutputStreamFactory()
Returns the output stream factory to be used when encoding asset models.
|
void |
removeAllAssetCodecs()
Removes all asset codecs from this
TLcdEarthAssetModelCodec . |
boolean |
removeAssetCodec(ILcdEarthAssetCodec aCodec)
Removes an asset codec from this
TLcdEarthAssetModelCodec if it is present. |
void |
save(ILcdModel aModel)
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 decoder
|
void |
setModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder)
Sets the model reference encoder
|
void |
setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
Sets the output stream factory to be used when encoding asset models.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
canDecodeSource, decodeModelMetadata, decodeModelMetadata, decodeSource, discoverDataSources
public TLcdEarthAssetModelCodec()
TLcdEarthAssetModelCodec
with the default model reference
encoder/decoder, input/output stream factories and asset codecs.public String getDisplayName()
ILcdModelDecoder
ILcdModelDecoder
.getDisplayName
in interface ILcdModelDecoder
getDisplayName
in interface ILcdModelEncoder
ILcdModelDecoder
.public ILcdModelReference getDefaultModelReference()
public ILcdModelReferenceDecoder getModelReferenceDecoder()
public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
aModelReferenceDecoder
- the model reference decoder.public ILcdModelReferenceEncoder getModelReferenceEncoder()
public void setModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder)
aModelReferenceEncoder
- the model reference encoderpublic boolean canDecodeSource(String aSourceName)
ILcdModelDecoder
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.
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 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 aDestination)
ILcdModelEncoder
canExport
in interface ILcdModelEncoder
aModel
- the model to be verified.aDestination
- 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 ILcdOutputStreamFactory getOutputStreamFactory()
public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
TLcdFileOutputStreamFactory
. The
output stream factory must not be null.aOutputStreamFactory
- an output stream factorypublic ILcdInputStreamFactory getInputStreamFactory()
public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
TLcdInputStreamFactory
. The
input stream factory must not be null.aInputStreamFactory
- an input stream factorypublic void export(ILcdModel aModel, String aDestination) throws IllegalArgumentException, IOException
ILcdModelEncoder
export
in interface ILcdModelEncoder
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.IllegalArgumentException
- if the model cannot be saved by this encoder (!canExport(aModel, aDestinationName)
).IOException
- if an I/O error occurs during encoding.public ILcdModel decode(String aSourceName) throws IOException
decode
in interface ILcdModelDecoder
aSourceName
- the name of the file to be decodedIOException
- if the file cannot be decodedILcdModelDecoder.canDecodeSource(String)
public void addAssetCodec(ILcdEarthAssetCodec aCodec)
TLcdEarthAssetModelCodec
. The newly added codec will
have precedence over all previously added codecs.aCodec
- the codec to be registeredpublic boolean removeAssetCodec(ILcdEarthAssetCodec aCodec)
TLcdEarthAssetModelCodec
if it is present.aCodec
- the codec to be removedpublic void removeAllAssetCodecs()
TLcdEarthAssetModelCodec
.public Collection<ILcdEarthAssetCodec> getAssetCodecs()