Interface IDocArchiveWriter

All Known Implementing Classes:
ArchiveWriter, FileArchiveWriter, FolderArchive, FolderArchiveWriter

public interface IDocArchiveWriter
An interface that wraps around a report archive for reading. A report archive may be, but is not limited to a zip file in compressed format, a folder in uncompressed format. Notice that the interface does not define archive file name, nor does it define folder name to store/uncompress the archive to. Setting such environments up is implementation class's responsibility.
  • Method Details

    • initialize

      void initialize() throws IOException
      This function must be called before the writer is used. initialize the document archive.
      Throws:
      IOException
    • getName

      String getName()
      Returns:
      the archive name
    • createRandomAccessStream

      RAOutputStream createRandomAccessStream(String relativePath) throws IOException
      Create a random access stream in the archive and return it.
      Parameters:
      relativePath - - relative path to report archive path. The path is based on Unix syntax, with the root of the archive denoted by "/". The initial "/" character can be skipped.
      Returns:
      RAOutputStream
      Throws:
      IOException
    • openRandomAccessStream

      RAOutputStream openRandomAccessStream(String relativePath) throws IOException
      Throws:
      IOException
    • createOutputStream

      RAOutputStream createOutputStream(String relativePath) throws IOException
      Throws:
      IOException
    • getOutputStream

      RAOutputStream getOutputStream(String relativePath) throws IOException
      Throws:
      IOException
    • getInputStream

      RAInputStream getInputStream(String relativePath) throws IOException
      Throws:
      IOException
    • dropStream

      boolean dropStream(String relativePath)
      Delete a stream from the archive. Note: Not all of the derived classes support this function. E.g. FileArchiveWriter doesn't support it.
      Parameters:
      relativePath - - the relative path of the stream
      Returns:
      whether the operation was successful
      Throws:
      IOException
    • exists

      boolean exists(String relativePath)
      Parameters:
      relativePath - - the relative stream path in the archive. The relative path is based on Unix syntax, with the root of the archive denoted by "/". The initial "/" character can be skipped.
      Returns:
      a list of strings representing the underlying stream names. The return values are in the relative path format too.
    • listStreams

      List<String> listStreams(String relativeStoragePath) throws IOException
      Parameters:
      relativeStoragePath - - the relative stream path in the archive. The relative path is based on Unix syntax, with the root of the archive denoted by "/". The initial "/" character can be skipped.
      Returns:
      a list of strings representing the underlying stream names. The return values are in the relative path format too.
      Throws:
      IOException
    • listAllStreams

      List<String> listAllStreams() throws IOException
      get all the stream in the archive file.
      Returns:
      Throws:
      IOException
    • setStreamSorter

      void setStreamSorter(IStreamSorter streamSorter)
      Set the stream sorter (if needed). The stream sorter will be used to sort the streams. If no stream sorter is set, the streams will be written in random order.
      Parameters:
      streamSorter - - the stream sorter
    • finish

      void finish() throws IOException
      This function must be called after the writer is used. finalizes the socument archive. This may involve compressing the archive to a single file. This also closes and finishes using the archive.
      Throws:
      IOException
    • flush

      void flush() throws IOException
      This function flushs all the buffers in the writer
      Throws:
      IOException
    • lock

      Object lock(String stream) throws IOException
      try to lock the stream
      Parameters:
      stream -
      Returns:
      the locker.
      Throws:
      IOException
    • unlock

      void unlock(Object locker)
      unlock the stream locked by the object.
      Parameters:
      locker - object returned by the lock().
      Throws:
      IOException
    • getArchiveFile

      IArchiveFile getArchiveFile()
      Get archive file
      Returns: