Class TLcdEarthAssetModelCodec

java.lang.Object
com.luciad.earth.metadata.format.TLcdEarthAssetModelCodec
All Implemented Interfaces:
ILcdModelDecoder, ILcdModelEncoder, Serializable

public class TLcdEarthAssetModelCodec extends Object implements ILcdModelDecoder, ILcdModelEncoder
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 Details

    • TLcdEarthAssetModelCodec

      public TLcdEarthAssetModelCodec()
      Constructs a new TLcdEarthAssetModelCodec with the default model reference encoder/decoder, input/output stream factories and asset codecs.
  • Method Details

    • getDisplayName

      public String getDisplayName()
      Description copied from interface: ILcdModelDecoder
      Returns a short, displayable name for the format that is decoded by this ILcdModelDecoder.
      Specified by:
      getDisplayName in interface ILcdModelDecoder
      Specified by:
      getDisplayName in interface ILcdModelEncoder
      Returns:
      the displayable name of this ILcdModelDecoder.
    • getDefaultModelReference

      public ILcdModelReference getDefaultModelReference()
      Returns the default model reference.
      Returns:
      the default model reference.
    • getModelReferenceDecoder

      public ILcdModelReferenceDecoder getModelReferenceDecoder()
      Returns the model reference decoder.
      Returns:
      the model reference decoder.
    • setModelReferenceDecoder

      public void setModelReferenceDecoder(ILcdModelReferenceDecoder aModelReferenceDecoder)
      Sets the model reference decoder
      Parameters:
      aModelReferenceDecoder - the model reference decoder.
    • getModelReferenceEncoder

      public ILcdModelReferenceEncoder getModelReferenceEncoder()
      Returns the model reference encoder.
      Returns:
      the model reference encoder.
    • setModelReferenceEncoder

      public void setModelReferenceEncoder(ILcdModelReferenceEncoder aModelReferenceEncoder)
      Sets the model reference encoder
      Parameters:
      aModelReferenceEncoder - the model reference encoder
    • canDecodeSource

      public boolean canDecodeSource(String aSourceName)
      Description copied from interface: ILcdModelDecoder
      Checks whether this model decoder can decode the specified data source. It is acceptable for this method to return 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.

      Specified by:
      canDecodeSource in interface ILcdModelDecoder
      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

      public boolean canSave(ILcdModel aModel)
      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 interface ILcdModelEncoder
      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

      public void save(ILcdModel aModel) throws IllegalArgumentException, IOException
      Description copied from interface: ILcdModelEncoder
      Saves the model to the location where it originally came from.
      Specified by:
      save in interface ILcdModelEncoder
      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

      public boolean canExport(ILcdModel aModel, String aDestination)
      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 interface ILcdModelEncoder
      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

      public ILcdOutputStreamFactory 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

      public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
      Sets the output stream factory to be used when encoding asset models. The default value is a TLcdFileOutputStreamFactory. The output stream factory must not be null.
      Parameters:
      aOutputStreamFactory - an output stream factory
    • getInputStreamFactory

      public ILcdInputStreamFactory 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

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Sets the input stream factory to be used when decoding asset models. The default value is a TLcdInputStreamFactory. 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 interface ILcdModelEncoder
      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

      public ILcdModel decode(String aSourceName) throws IOException
      Decodes an asset model from the given file.
      Specified by:
      decode in interface ILcdModelDecoder
      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

      public void addAssetCodec(ILcdEarthAssetCodec aCodec)
      Adds an asset codec to this TLcdEarthAssetModelCodec. The newly added codec will have precedence over all previously added codecs.
      Parameters:
      aCodec - the codec to be registered
    • removeAssetCodec

      public boolean removeAssetCodec(ILcdEarthAssetCodec aCodec)
      Removes an asset codec from this TLcdEarthAssetModelCodec 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 this TLcdEarthAssetModelCodec.
    • getAssetCodecs

      public Collection<ILcdEarthAssetCodec> getAssetCodecs()
      Returns the current collection of asset codecs.
      Returns:
      the current collection of asset codecs