Package com.luciad.lucy.workspace
Class ALcyWorkspaceCodecDelegate
java.lang.Object
com.luciad.lucy.workspace.ALcyWorkspaceCodecDelegate
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 ALcyWorkspaceCodecDelegate
s 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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionboolean
canEncode
(ALcyWorkspaceCodec aWSCodec) This method returns true if thisALcyWorkspaceCodecDelegate
can encode information, false otherwise.abstract void
decode
(ALcyWorkspaceCodec aWSCodec, InputStream aIn) Decode the settings from the givenInputStream
.abstract void
encode
(ALcyWorkspaceCodec aWSCodec, OutputStream aOut) Encode the settings into the givenOutputStream
.abstract String
getUID()
A unique identifier for thisALcyWorkspaceCodecDelegate
.
-
Constructor Details
-
ALcyWorkspaceCodecDelegate
public ALcyWorkspaceCodecDelegate()
-
-
Method Details
-
getUID
A unique identifier for thisALcyWorkspaceCodecDelegate
. The UID will be used to make sure that a workspace part that is encoded by aALcyWorkspaceCodecDelegate
with some UID can only be decoded by aALcyWorkspaceCodecDelegate
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 theTLcyWorkspaceManager
. Unique means that at any time no twoALcyWorkspaceCodecDelegate
s orALcyWorkspaceObjectCodec
s with the samegetUID()
must be registered with the sameTLcyWorkspaceManager
. Therefore it is suggested to use a package name prefix for the UID's. The UID's of allALcyWorkspaceObjectCodec
s 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 givenOutputStream
.- Parameters:
aWSCodec
- TheALcyWorkspaceCodec
, provided in case object references need to be stored.aOut
- TheOutputStream
to write the settings to.- Throws:
IOException
- In case of IO failure.TLcyWorkspaceAbortedException
- In case the user aborted (e.g. canceled) the operation.
-
canEncode
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 aALcyWorkspaceCodecDelegate
that never encodes anything, but only reads legacy data. The default implementation returnstrue
.This method should only be invoked by an
ALcyWorkspaceCodec
, never by user code.- Parameters:
aWSCodec
- TheALcyWorkspaceCodec
, 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 givenInputStream
.- Parameters:
aWSCodec
- TheALcyWorkspaceCodec
, provided in case object references need to be restored.aIn
- TheInputStream
to read the settings from.- Throws:
IOException
- In case of IO failure.TLcyWorkspaceAbortedException
- In case the user aborted (e.g. canceled) the operation.
-