Class TLcyBlobWorkspaceCodec
- All Implemented Interfaces:
ILcdInputStreamFactoryCapable
,ILcdOutputStreamFactoryCapable
,ILcdPropertyChangeSource
- Direct Known Subclasses:
TLcyFileWorkspaceCodec
Extension of ALcyWorkspaceCodec
that only uses a single OutputStream
and
a single InputStream
to store/restore workspaces.
This makes it a good class to use if you want for example save a workspace to a file (see TLcyFileWorkspaceCodec
)
or to a database.
In both those cases, having a single InputStream
or OutputStream
facilitates things.
Where the super class creates all little streams to store/restore the workspace using retrieveInputStream(String)
and retrieveOutputStream(String)
, this implementation merges all those little streams into one big stream.
The single stream is created by the ILcdInputStreamFactory
(for decoding) or the
ILcdOutputStreamFactory
(for encoding).
Those factories can be set using setInputStreamFactory(ILcdInputStreamFactory)
and setOutputStreamFactory(ILcdOutputStreamFactory)
.
- Since:
- 2015.1
-
Constructor Summary
ModifierConstructorDescriptionprotected
TLcyBlobWorkspaceCodec
(ILcyLucyEnv aLucyEnv, TLcyWorkspaceManager aWorkspaceManager, ILcdInputStreamFactory aInputStreamFactory, ILcdOutputStreamFactory aOutputStreamFactory) Creates a newTLcyBlobWorkspaceCodec
instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
canDecodeWorkspace
(String aSourceName) Returns true if the given aSourceName can be decoded.boolean
canDecodeWorkspace
(String aSourceName, List<String> aReasonsSFCT) Returns true if the given source name can be decoded, false otherwise.boolean
canEncodeWorkspace
(String aDestinationName) Returns true if the workspace can be encoded to the givenaDestinationName
void
decodeWorkspace
(String aSourceName) Decodes the workspace.String[]
decodeWorkspaceDelegateCodecIDs
(String aSourceName) Decodes the workspace codec delegate UID's used by the given workspace.void
encodeWorkspace
(String aDestinationName) Encodes the workspace.Returns the input stream factory that is used.Returns the output stream factory that is used.protected InputStream
retrieveInputStream
(String aUID) Returns anInputStream
for the given aUID.protected OutputStream
retrieveOutputStream
(String aUID) Returns anOutputStream
for the given aUID.void
setInputStreamFactory
(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory to be used.void
setOutputStreamFactory
(ILcdOutputStreamFactory aOutputStreamFactory) Sets the output stream factory to be used.Methods inherited from class com.luciad.lucy.workspace.ALcyWorkspaceCodec
addPropertyChangeListener, addPropertyChangeListener, canEncodeReference, canEncodeReference, checkApplicationHeader, createApplicationHeader, decodeFromInputStream, decodePath, decodeReference, encodeObject, encodePath, encodeReference, encodeReference, firePropertyChange, flushWorkspaceStorageName, getLogListener, getParentComponent, getStatusListener, getWorkspaceManager, getWorkspaceStorageName, removePropertyChangeListener, removePropertyChangeListener, setLogListener, setParentComponent, setStatusListener
-
Constructor Details
-
TLcyBlobWorkspaceCodec
protected TLcyBlobWorkspaceCodec(ILcyLucyEnv aLucyEnv, TLcyWorkspaceManager aWorkspaceManager, ILcdInputStreamFactory aInputStreamFactory, ILcdOutputStreamFactory aOutputStreamFactory) Creates a newTLcyBlobWorkspaceCodec
instance.- Parameters:
aLucyEnv
- The Lucy back-endaWorkspaceManager
- The workspace manageraInputStreamFactory
- The input stream factoryaOutputStreamFactory
- The output stream factory
-
-
Method Details
-
setInputStreamFactory
Description copied from interface:ILcdInputStreamFactoryCapable
Sets the input stream factory to be used.- Specified by:
setInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Parameters:
aInputStreamFactory
- the input stream factory to be used.
-
getInputStreamFactory
Description copied from interface:ILcdInputStreamFactoryCapable
Returns the input stream factory that is used.- Specified by:
getInputStreamFactory
in interfaceILcdInputStreamFactoryCapable
- Returns:
- the input stream factory that is used.
-
setOutputStreamFactory
Description copied from interface:ILcdOutputStreamFactoryCapable
Sets the output stream factory to be used.- Specified by:
setOutputStreamFactory
in interfaceILcdOutputStreamFactoryCapable
- Parameters:
aOutputStreamFactory
- the output stream factory to be used.
-
getOutputStreamFactory
Description copied from interface:ILcdOutputStreamFactoryCapable
Returns the output stream factory that is used.- Specified by:
getOutputStreamFactory
in interfaceILcdOutputStreamFactoryCapable
- Returns:
- the output stream factory that is used.
-
canDecodeWorkspace
Description copied from class:ALcyWorkspaceCodec
Returns true if the given aSourceName can be decoded.- Specified by:
canDecodeWorkspace
in classALcyWorkspaceCodec
- Parameters:
aSourceName
- The source name to check.- Returns:
- true if the given aSourceName can be decoded.
-
canDecodeWorkspace
Description copied from class:ALcyWorkspaceCodec
Returns true if the given source name can be decoded, false otherwise. The second argument of the method is a list of strings which can be used to pass a description to the caller of this method.
For example when a workspace cannot be decoded for a certain reason, a description of that reason can be added to the list of strings.- Overrides:
canDecodeWorkspace
in classALcyWorkspaceCodec
- Parameters:
aSourceName
- The source name to checkaReasonsSFCT
- A side-effect parameter to which this method may add reasons on why it returnedtrue
orfalse
- Returns:
true
if the given source name can be decoded,false
otherwise
-
decodeWorkspaceDelegateCodecIDs
Description copied from class:ALcyWorkspaceCodec
Decodes the workspace codec delegate UID's used by the given workspace.- Overrides:
decodeWorkspaceDelegateCodecIDs
in classALcyWorkspaceCodec
- Parameters:
aSourceName
- The source name of the workspace. It is up to subclasses of this class to interpret this string, e.g. as a file name.- Returns:
- an array containing the UID's of the workspace codec delegates used in the given workspace
- Throws:
IOException
- if the workspace file is not compatible with this application, or if a fatal I/O exception occurs- See Also:
-
decodeWorkspace
Description copied from class:ALcyWorkspaceCodec
Decodes the workspace. This method must never be invoked by user code, insteadTLcyWorkspaceManager.decodeWorkspace(String)
must be used. Decoding the workspace means all encoded parts will be decoded by the correctALcyWorkspaceCodecDelegate
. The UID is used to find the correctALcyWorkspaceCodecDelegate
. When such anALcyWorkspaceCodecDelegate
is decoding its part, it might need to restore an object reference (e.g. to an ILcdGXYLayer). It can do so usingALcyWorkspaceCodec.decodeReference(String)
.- Overrides:
decodeWorkspace
in classALcyWorkspaceCodec
- Parameters:
aSourceName
- The source name of the workspace. It is up to subclasses of this class to interpret this string, e.g. as a file name.- Throws:
IOException
- In case of fatal IO failure.TLcyWorkspaceAbortedException
- In case the operation is aborted, e.g. because the user canceled it.
-
canEncodeWorkspace
Returns true if the workspace can be encoded to the givenaDestinationName
The default implementation assumes that the UI enforces a valid destination name, and simply returns
true
independent of the value ofaDestinationName
.- Specified by:
canEncodeWorkspace
in classALcyWorkspaceCodec
- Parameters:
aDestinationName
- The destination name to check.- Returns:
- true if the workspace can be encoded to the given
aDestinationName
-
encodeWorkspace
public void encodeWorkspace(String aDestinationName) throws IOException, TLcyWorkspaceAbortedException Description copied from class:ALcyWorkspaceCodec
Encodes the workspace. This method must never be invoked by user code, insteadTLcyWorkspaceManager.encodeWorkspace(String)
must be used. Encoding the workspace means all registeredALcyWorkspaceCodecDelegate
s will be asked to encode their part. When aALcyWorkspaceCodecDelegate
is encoding its part, it might need to store an object reference (e.g. a reference to an ILcdGXYLayer). It can do so usingALcyWorkspaceCodec.encodeReference(Object)
. This method must only be used ifALcyWorkspaceCodec.canEncodeWorkspace(String)
for the same aDestinationName returns true.- Overrides:
encodeWorkspace
in classALcyWorkspaceCodec
- Parameters:
aDestinationName
- The destination name of the workspace. It is up to subclasses to interpret this string, e.g. as a file name.- Throws:
IOException
- In case of fatal IO failure.TLcyWorkspaceAbortedException
- In case the operation is aborted, e.g. because the user canceled it.
-
retrieveOutputStream
Description copied from class:ALcyWorkspaceCodec
Returns anOutputStream
for the given aUID. The returnedOutputStream
should be a new instance for every UID, as several streams might be open at the same time, and data can be written to any of those open streams. This method is used several times during workspace endoding: the stream for every UID represents one little part of the workspace. During decoding,retrieveInputStream(aUID)
must return anInputStream
that refers to the same data block as the one written to the correspondingOutputStream
. Subclasses can implement this method in various ways: they can store every stream in a separate file, they can store all streams in one single file, they can store the streams in a database, ...- Specified by:
retrieveOutputStream
in classALcyWorkspaceCodec
- Parameters:
aUID
- The identifier to retrieve anOutputStream
for.- Returns:
- The
OutputStream
- Throws:
IOException
- In case of fatal IO failure.- See Also:
-
retrieveInputStream
Description copied from class:ALcyWorkspaceCodec
Returns anInputStream
for the given aUID. The returnedInputStream
should be a new instance for every UID, as several streams might be open at the same time, and data can be read from any of those open streams. It is assumed that every stream can be read until end of stream. This method is used several times during workspace dedoding: the stream for every UID represents one little part of the workspace. This method must return anInputStream
referring to the same data block as the data that was written to theOutputStream
created byALcyWorkspaceCodec.retrieveOutputStream(String)
for the same aUID. Subclasses can implement this method in various ways: they can retrieve every stream from a separate file, they can retrieve all streams from one single file, they can retrieve the streams from a database, ...- Specified by:
retrieveInputStream
in classALcyWorkspaceCodec
- Parameters:
aUID
- The identifier to retrieve anOutputStream
for.- Returns:
- The
OutputStream
- Throws:
IOException
- In case of fatal IO failure.- See Also:
-