Class TLcyBlobWorkspaceCodec

java.lang.Object
com.luciad.lucy.workspace.ALcyWorkspaceCodec
com.luciad.lucy.workspace.TLcyBlobWorkspaceCodec
All Implemented Interfaces:
ILcdInputStreamFactoryCapable, ILcdOutputStreamFactoryCapable, ILcdPropertyChangeSource
Direct Known Subclasses:
TLcyFileWorkspaceCodec

public class TLcyBlobWorkspaceCodec extends ALcyWorkspaceCodec implements ILcdInputStreamFactoryCapable, ILcdOutputStreamFactoryCapable

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 Details

    • TLcyBlobWorkspaceCodec

      protected TLcyBlobWorkspaceCodec(ILcyLucyEnv aLucyEnv, TLcyWorkspaceManager aWorkspaceManager, ILcdInputStreamFactory aInputStreamFactory, ILcdOutputStreamFactory aOutputStreamFactory)
      Creates a new TLcyBlobWorkspaceCodec instance.
      Parameters:
      aLucyEnv - The Lucy back-end
      aWorkspaceManager - The workspace manager
      aInputStreamFactory - The input stream factory
      aOutputStreamFactory - The output stream factory
  • Method Details

    • setInputStreamFactory

      public void setInputStreamFactory(ILcdInputStreamFactory aInputStreamFactory)
      Description copied from interface: ILcdInputStreamFactoryCapable
      Sets the input stream factory to be used.
      Specified by:
      setInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Parameters:
      aInputStreamFactory - the input stream factory to be used.
    • getInputStreamFactory

      public ILcdInputStreamFactory getInputStreamFactory()
      Description copied from interface: ILcdInputStreamFactoryCapable
      Returns the input stream factory that is used.
      Specified by:
      getInputStreamFactory in interface ILcdInputStreamFactoryCapable
      Returns:
      the input stream factory that is used.
    • setOutputStreamFactory

      public void setOutputStreamFactory(ILcdOutputStreamFactory aOutputStreamFactory)
      Description copied from interface: ILcdOutputStreamFactoryCapable
      Sets the output stream factory to be used.
      Specified by:
      setOutputStreamFactory in interface ILcdOutputStreamFactoryCapable
      Parameters:
      aOutputStreamFactory - the output stream factory to be used.
    • getOutputStreamFactory

      public ILcdOutputStreamFactory getOutputStreamFactory()
      Description copied from interface: ILcdOutputStreamFactoryCapable
      Returns the output stream factory that is used.
      Specified by:
      getOutputStreamFactory in interface ILcdOutputStreamFactoryCapable
      Returns:
      the output stream factory that is used.
    • canDecodeWorkspace

      public boolean canDecodeWorkspace(String aSourceName)
      Description copied from class: ALcyWorkspaceCodec
      Returns true if the given aSourceName can be decoded.
      Specified by:
      canDecodeWorkspace in class ALcyWorkspaceCodec
      Parameters:
      aSourceName - The source name to check.
      Returns:
      true if the given aSourceName can be decoded.
    • canDecodeWorkspace

      public boolean canDecodeWorkspace(String aSourceName, List<String> aReasonsSFCT)
      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 class ALcyWorkspaceCodec
      Parameters:
      aSourceName - The source name to check
      aReasonsSFCT - A side-effect parameter to which this method may add reasons on why it returned true or false
      Returns:
      true if the given source name can be decoded, false otherwise
    • decodeWorkspaceDelegateCodecIDs

      public String[] decodeWorkspaceDelegateCodecIDs(String aSourceName) throws IOException
      Description copied from class: ALcyWorkspaceCodec
      Decodes the workspace codec delegate UID's used by the given workspace.
      Overrides:
      decodeWorkspaceDelegateCodecIDs in class ALcyWorkspaceCodec
      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

      public void decodeWorkspace(String aSourceName) throws IOException, TLcyWorkspaceAbortedException
      Description copied from class: ALcyWorkspaceCodec
      Decodes the workspace. This method must never be invoked by user code, instead TLcyWorkspaceManager.decodeWorkspace(String) must be used.

      Decoding the workspace means all encoded parts will be decoded by the correct ALcyWorkspaceCodecDelegate. The UID is used to find the correct ALcyWorkspaceCodecDelegate. When such an ALcyWorkspaceCodecDelegate is decoding its part, it might need to restore an object reference (e.g. to an ILcdGXYLayer). It can do so using ALcyWorkspaceCodec.decodeReference(String).

      Overrides:
      decodeWorkspace in class ALcyWorkspaceCodec
      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

      public boolean canEncodeWorkspace(String aDestinationName)
      Returns true if the workspace can be encoded to the given aDestinationName

      The default implementation assumes that the UI enforces a valid destination name, and simply returns true independent of the value of aDestinationName.

      Specified by:
      canEncodeWorkspace in class ALcyWorkspaceCodec
      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, instead TLcyWorkspaceManager.encodeWorkspace(String) must be used.

      Encoding the workspace means all registered ALcyWorkspaceCodecDelegates will be asked to encode their part. When a ALcyWorkspaceCodecDelegate is encoding its part, it might need to store an object reference (e.g. a reference to an ILcdGXYLayer). It can do so using ALcyWorkspaceCodec.encodeReference(Object).

      This method must only be used if ALcyWorkspaceCodec.canEncodeWorkspace(String) for the same aDestinationName returns true.

      Overrides:
      encodeWorkspace in class ALcyWorkspaceCodec
      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

      protected OutputStream retrieveOutputStream(String aUID) throws IOException
      Description copied from class: ALcyWorkspaceCodec
      Returns an OutputStream for the given aUID. The returned OutputStream 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 an InputStream that refers to the same data block as the one written to the corresponding OutputStream.

      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 class ALcyWorkspaceCodec
      Parameters:
      aUID - The identifier to retrieve an OutputStream for.
      Returns:
      The OutputStream
      Throws:
      IOException - In case of fatal IO failure.
      See Also:
    • retrieveInputStream

      protected InputStream retrieveInputStream(String aUID) throws IOException
      Description copied from class: ALcyWorkspaceCodec
      Returns an InputStream for the given aUID. The returned InputStream 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 an InputStream referring to the same data block as the data that was written to the OutputStream created by ALcyWorkspaceCodec.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 class ALcyWorkspaceCodec
      Parameters:
      aUID - The identifier to retrieve an OutputStream for.
      Returns:
      The OutputStream
      Throws:
      IOException - In case of fatal IO failure.
      See Also: