Class ZipMultiChunk

    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Closes a multichunk after writing/reading.
      java.io.InputStream getChunkInputStream​(byte[] checksum)
      In read mode, this method can be used to read Chunks in random access mode, using a chunk checksum as identifier.
      long getSize()  
      boolean isFull()
      In write mode, this method determines the fill state of the multichunk and returns whether or not a new chunk can still be added.
      Chunk read()
      In read mode, this method can be used to sequentially read Chunks from a multichunk.
      void write​(Chunk chunk)
      In write mode, this method can be used to write Chunks to a multichunk.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ZipMultiChunk

        public ZipMultiChunk​(java.io.InputStream is)
      • ZipMultiChunk

        public ZipMultiChunk​(java.io.File file)
                      throws java.util.zip.ZipException,
                             java.io.IOException
        Throws:
        java.util.zip.ZipException
        java.io.IOException
    • Method Detail

      • isFull

        public boolean isFull()
        Description copied from class: MultiChunk
        In write mode, this method determines the fill state of the multichunk and returns whether or not a new chunk can still be added. It is used by the Deduper.
        Overrides:
        isFull in class MultiChunk
        Returns:
        Returns true if no more chunks should be added and the chunk should be closed, false otherwise
      • write

        public void write​(Chunk chunk)
                   throws java.io.IOException
        Description copied from class: MultiChunk
        In write mode, this method can be used to write Chunks to a multichunk.

        Implementations must increase the MultiChunk.size by the amount written to the multichunk (input size sufficient) and make sure that (if required) a header is written for the first chunk.

        Implementations do not have to check whether or not a multichunk is full. This should be done outside the multichunker/multichunk as part of the deduplication algorithm in the Deduper.

        Specified by:
        write in class MultiChunk
        Parameters:
        chunk - Chunk to be written to the multichunk container
        Throws:
        java.io.IOException - If an exception occurs when writing to the multichunk
      • getChunkInputStream

        public java.io.InputStream getChunkInputStream​(byte[] checksum)
                                                throws java.io.IOException
        Description copied from class: MultiChunk
        In read mode, this method can be used to read Chunks in random access mode, using a chunk checksum as identifier. The method returns a chunk input stream (the chunk's data) if the chunk is found, and null otherwise.

        If all chunks are read from a multichunk sequentially, the MultiChunk.read() method should be used instead.

        Specified by:
        getChunkInputStream in class MultiChunk
        Parameters:
        checksum - The checksum identifying a chunk instance
        Returns:
        Returns a chunk input stream (chunk data) if the chunk can be found in the multichunk, or null otherwise
        Throws:
        java.io.IOException - If an exception occurs when reading from the multichunk
      • read

        public Chunk read()
                   throws java.io.IOException
        Description copied from class: MultiChunk
        In read mode, this method can be used to sequentially read Chunks from a multichunk. The method returns a chunk until no more chunks are available, at which point it will return null.

        If random read access on a multichunk is desired, the getChunkInputStream() method should be used instead.

        Specified by:
        read in class MultiChunk
        Returns:
        Returns the next chunk in the opened multichunk, or null if no chunk is available (anymore)
        Throws:
        java.io.IOException - If an exception occurs when reading from the multichunk
      • close

        public void close()
                   throws java.io.IOException
        Description copied from class: MultiChunk
        Closes a multichunk after writing/reading.

        Implementations should close the underlying input/output stream (depending on whether the chunk was opened in read or write mode.

        Specified by:
        close in class MultiChunk
        Throws:
        java.io.IOException - If an exception occurs when closing the multichunk