Class ALcyWorkspaceCodecDelegate

java.lang.Object
com.luciad.lucy.workspace.ALcyWorkspaceCodecDelegate

public abstract class ALcyWorkspaceCodecDelegate extends Object
An ALcyWorkspaceCodecDelegate is responsible for encoding/decoding a part of the workspace. Addons will typically register an ALcyWorkspaceCodecDelegate to allow them to store/restore their settings into/from the workspace.

Instances of ALcyWorkspaceCodecDelegate must be registered with TLcyWorkspaceManager. Every registered ALcyWorkspaceCodecDelegate will be asked to encode its part of the workspace by means of encode(ALcyWorkspaceCodec, java.io.OutputStream). Decoding a workspace will trigger decode(ALcyWorkspaceCodec, java.io.InputStream) on every ALcyWorkspaceCodecDelegate that encoded a part. To remember which part was encoded by which ALcyWorkspaceCodecDelegate (and therefore which ALcyWorkspaceCodecDelegate must decode it) , the String returned by getUID() will be used.

If an ALcyWorkspaceCodecDelegates needs to encode a path, it is advised to use ALcyWorkspaceCodec.encodePath(String). This, for example, allows implementations of ALcyWorkspaceCodec to store paths relative to the location of the workspace file.

  • Constructor Details

    • ALcyWorkspaceCodecDelegate

      public ALcyWorkspaceCodecDelegate()
  • Method Details

    • getUID

      public abstract String getUID()
      A unique identifier for this ALcyWorkspaceCodecDelegate.

      The UID will be used to make sure that a workspace part that is encoded by a ALcyWorkspaceCodecDelegate with some UID can only be decoded by a ALcyWorkspaceCodecDelegate with the same UID. For this purpose it is mandatory that, whenever the application is restarted, ALcyWorkspaceCodecDelegate's with the same UID's are registered with the TLcyWorkspaceManager.

      Unique means that at any time no two ALcyWorkspaceCodecDelegates or ALcyWorkspaceObjectCodecs with the same getUID() must be registered with the same TLcyWorkspaceManager. Therefore it is suggested to use a package name prefix for the UID's. The UID's of all ALcyWorkspaceObjectCodecs added by Lucy itself start with "com.luciad".

      The UID must not be 'null', must not be the empty string "", must not contain spaces and must not start with '%'

      Returns:
      The UID for this ALcyWorkspaceCodecDelegate.
    • encode

      public abstract void encode(ALcyWorkspaceCodec aWSCodec, OutputStream aOut) throws IOException, TLcyWorkspaceAbortedException
      Encode the settings into the given OutputStream.
      Parameters:
      aWSCodec - The ALcyWorkspaceCodec, provided in case object references need to be stored.
      aOut - The OutputStream to write the settings to.
      Throws:
      IOException - In case of IO failure.
      TLcyWorkspaceAbortedException - In case the user aborted (e.g. canceled) the operation.
    • canEncode

      public boolean canEncode(ALcyWorkspaceCodec aWSCodec)

      This method returns true if this ALcyWorkspaceCodecDelegate can encode information, false otherwise. It can be useful to override this method to decide at run-time if this codec needs to store information in the workspace or not. It also allows to easily implement a ALcyWorkspaceCodecDelegate that never encodes anything, but only reads legacy data. The default implementation returns true.

      This method should only be invoked by an ALcyWorkspaceCodec, never by user code.

      Parameters:
      aWSCodec - The ALcyWorkspaceCodec, provided as contextual information.
      Returns:
      True if information can be encoded, false otherwise.
    • decode

      public abstract void decode(ALcyWorkspaceCodec aWSCodec, InputStream aIn) throws IOException, TLcyWorkspaceAbortedException
      Decode the settings from the given InputStream.
      Parameters:
      aWSCodec - The ALcyWorkspaceCodec, provided in case object references need to be restored.
      aIn - The InputStream to read the settings from.
      Throws:
      IOException - In case of IO failure.
      TLcyWorkspaceAbortedException - In case the user aborted (e.g. canceled) the operation.