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
ConstructorsModifierConstructorDescriptionprotectedTLcyBlobWorkspaceCodec(ILcyLucyEnv aLucyEnv, TLcyWorkspaceManager aWorkspaceManager, ILcdInputStreamFactory aInputStreamFactory, ILcdOutputStreamFactory aOutputStreamFactory) Creates a newTLcyBlobWorkspaceCodecinstance. -
Method Summary
Modifier and TypeMethodDescriptionbooleancanDecodeWorkspace(String aSourceName) Returns true if the given aSourceName can be decoded.booleancanDecodeWorkspace(String aSourceName, List<String> aReasonsSFCT) Returns true if the given source name can be decoded, false otherwise.booleancanEncodeWorkspace(String aDestinationName) Returns true if the workspace can be encoded to the givenaDestinationNamevoiddecodeWorkspace(String aSourceName) Decodes the workspace.String[]decodeWorkspaceDelegateCodecIDs(String aSourceName) Decodes the workspace codec delegate UID's used by the given workspace.voidencodeWorkspace(String aDestinationName) Encodes the workspace.Returns the input stream factory that is used.Returns the output stream factory that is used.protected InputStreamretrieveInputStream(String aUID) Returns anInputStreamfor the given aUID.protected OutputStreamretrieveOutputStream(String aUID) Returns anOutputStreamfor the given aUID.voidsetInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory) Sets the input stream factory to be used.voidsetOutputStreamFactory(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 newTLcyBlobWorkspaceCodecinstance.- Parameters:
aLucyEnv- The Lucy back-endaWorkspaceManager- The workspace manageraInputStreamFactory- The input stream factoryaOutputStreamFactory- The output stream factory
-
-
Method Details
-
setInputStreamFactory
Description copied from interface:ILcdInputStreamFactoryCapableSets the input stream factory to be used.- Specified by:
setInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Parameters:
aInputStreamFactory- the input stream factory to be used.
-
getInputStreamFactory
Description copied from interface:ILcdInputStreamFactoryCapableReturns the input stream factory that is used.- Specified by:
getInputStreamFactoryin interfaceILcdInputStreamFactoryCapable- Returns:
- the input stream factory that is used.
-
setOutputStreamFactory
Description copied from interface:ILcdOutputStreamFactoryCapableSets the output stream factory to be used.- Specified by:
setOutputStreamFactoryin interfaceILcdOutputStreamFactoryCapable- Parameters:
aOutputStreamFactory- the output stream factory to be used.
-
getOutputStreamFactory
Description copied from interface:ILcdOutputStreamFactoryCapableReturns the output stream factory that is used.- Specified by:
getOutputStreamFactoryin interfaceILcdOutputStreamFactoryCapable- Returns:
- the output stream factory that is used.
-
canDecodeWorkspace
Description copied from class:ALcyWorkspaceCodecReturns true if the given aSourceName can be decoded.- Specified by:
canDecodeWorkspacein classALcyWorkspaceCodec- Parameters:
aSourceName- The source name to check.- Returns:
- true if the given aSourceName can be decoded.
-
canDecodeWorkspace
Description copied from class:ALcyWorkspaceCodecReturns 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:
canDecodeWorkspacein classALcyWorkspaceCodec- Parameters:
aSourceName- The source name to checkaReasonsSFCT- A side-effect parameter to which this method may add reasons on why it returnedtrueorfalse- Returns:
trueif the given source name can be decoded,falseotherwise
-
decodeWorkspaceDelegateCodecIDs
Description copied from class:ALcyWorkspaceCodecDecodes the workspace codec delegate UID's used by the given workspace.- Overrides:
decodeWorkspaceDelegateCodecIDsin 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:ALcyWorkspaceCodecDecodes 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 anALcyWorkspaceCodecDelegateis decoding its part, it might need to restore an object reference (e.g. to an ILcdGXYLayer). It can do so usingALcyWorkspaceCodec.decodeReference(String).- Overrides:
decodeWorkspacein 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 givenaDestinationNameThe default implementation assumes that the UI enforces a valid destination name, and simply returns
trueindependent of the value ofaDestinationName.- Specified by:
canEncodeWorkspacein 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:ALcyWorkspaceCodecEncodes the workspace. This method must never be invoked by user code, insteadTLcyWorkspaceManager.encodeWorkspace(String)must be used. Encoding the workspace means all registeredALcyWorkspaceCodecDelegates will be asked to encode their part. When aALcyWorkspaceCodecDelegateis 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:
encodeWorkspacein 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:ALcyWorkspaceCodecReturns anOutputStreamfor the given aUID. The returnedOutputStreamshould 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 anInputStreamthat 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:
retrieveOutputStreamin classALcyWorkspaceCodec- Parameters:
aUID- The identifier to retrieve anOutputStreamfor.- Returns:
- The
OutputStream - Throws:
IOException- In case of fatal IO failure.- See Also:
-
retrieveInputStream
Description copied from class:ALcyWorkspaceCodecReturns anInputStreamfor the given aUID. The returnedInputStreamshould 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 anInputStreamreferring to the same data block as the data that was written to theOutputStreamcreated 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:
retrieveInputStreamin classALcyWorkspaceCodec- Parameters:
aUID- The identifier to retrieve anOutputStreamfor.- Returns:
- The
OutputStream - Throws:
IOException- In case of fatal IO failure.- See Also:
-