public abstract class ALcyWorkspaceCodecDelegate extends Object
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 and Description |
---|
ALcyWorkspaceCodecDelegate() |
Modifier and Type | Method and Description |
---|---|
boolean |
canEncode(ALcyWorkspaceCodec aWSCodec)
This method returns true if this
ALcyWorkspaceCodecDelegate can encode
information, false otherwise. |
abstract void |
decode(ALcyWorkspaceCodec aWSCodec,
InputStream aIn)
Decode the settings from the given
InputStream . |
abstract void |
encode(ALcyWorkspaceCodec aWSCodec,
OutputStream aOut)
Encode the settings into the given
OutputStream . |
abstract String |
getUID()
A unique identifier for this
ALcyWorkspaceCodecDelegate . |
public abstract String getUID()
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 ALcyWorkspaceCodecDelegate
s or
ALcyWorkspaceObjectCodec
s 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 ALcyWorkspaceObjectCodec
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 '%'ALcyWorkspaceCodecDelegate
.public abstract void encode(ALcyWorkspaceCodec aWSCodec, OutputStream aOut) throws IOException, TLcyWorkspaceAbortedException
OutputStream
.aWSCodec
- The ALcyWorkspaceCodec
, provided in case object references need to
be stored.aOut
- The OutputStream
to write the settings to.IOException
- In case of IO failure.TLcyWorkspaceAbortedException
- In case the user aborted (e.g. canceled) the operation.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.
aWSCodec
- The ALcyWorkspaceCodec
, provided as contextual information.public abstract void decode(ALcyWorkspaceCodec aWSCodec, InputStream aIn) throws IOException, TLcyWorkspaceAbortedException
InputStream
.aWSCodec
- The ALcyWorkspaceCodec
, provided in case object references need to
be restored.aIn
- The InputStream
to read the settings from.IOException
- In case of IO failure.TLcyWorkspaceAbortedException
- In case the user aborted (e.g. canceled) the operation.