net.sf.sevenzipjbinding.impl
Class VolumedArchiveInStream

java.lang.Object
  extended by net.sf.sevenzipjbinding.impl.VolumedArchiveInStream
All Implemented Interfaces:
java.io.Closeable, IInStream, ISeekableStream, ISequentialInStream

public class VolumedArchiveInStream
extends java.lang.Object
implements IInStream

This helper class allows merging multiple instances of IInStream interface into one. This is helpful for accessing 7z volumed archives. 7z splits its archives into volumes on the byte layout. Each archive volume gets extension .7z.nnn (.7z.001, .7z.002, .7z.003, ...). Such archives can be reassembled into single archive file using simple concatenation:

cat name.7z.* > name.7z
To use this you need to implement IArchiveOpenVolumeCallback interface.

Since:
4.65-1
Author:
Boris Brodski

Field Summary
 
Fields inherited from interface net.sf.sevenzipjbinding.ISeekableStream
SEEK_CUR, SEEK_END, SEEK_SET
 
Constructor Summary
VolumedArchiveInStream(IArchiveOpenVolumeCallback archiveOpenVolumeCallback)
          Creates instance of VolumedArchiveInStream using IArchiveOpenVolumeCallback.
VolumedArchiveInStream(java.lang.String firstVolumeFilename, IArchiveOpenVolumeCallback archiveOpenVolumeCallback)
          Creates instance of VolumedArchiveInStream using IArchiveOpenVolumeCallback.
 
Method Summary
 void close()
           
 int read(byte[] data)
          $Reads at least 1 and maximum data.length bytes from the in-stream.
 long seek(long offset, int seekOrigin)
          $Move current location pointer to the new offset depending on seekOrigin.

Note: depending on the archive format and the data size this method may be called from different threads.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VolumedArchiveInStream

public VolumedArchiveInStream(IArchiveOpenVolumeCallback archiveOpenVolumeCallback)
                       throws SevenZipException
Creates instance of VolumedArchiveInStream using IArchiveOpenVolumeCallback. The name of the first archive volume will be asked using IArchiveOpenVolumeCallback.getProperty(PropID) with the propID=PropID.NAME. The file name should ends with .7z.001 or SevenZipException will be thrown.

Parameters:
archiveOpenVolumeCallback - call back implementation used to access different volumes of archive.
Throws:
SevenZipException - 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.

VolumedArchiveInStream

public VolumedArchiveInStream(java.lang.String firstVolumeFilename,
                              IArchiveOpenVolumeCallback archiveOpenVolumeCallback)
                       throws SevenZipException
Creates instance of VolumedArchiveInStream using IArchiveOpenVolumeCallback.

Parameters:
firstVolumeFilename - the file name of the first volume.
archiveOpenVolumeCallback - call back implementation used to access different volumes of archive. The file name should ends with .7z.001 or SevenZipException will be thrown.
Throws:
SevenZipException - 7-Zip or 7-Zip-JBinding error occur. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.
Method Detail

seek

public long seek(long offset,
                 int seekOrigin)
          throws SevenZipException
$Move current location pointer to the new offset depending on seekOrigin.

Note: depending on the archive format and the data size this method may be called from different threads. Synchronized implementation may be required.

Specified by:
seek in interface ISeekableStream
Parameters:
offset - absolute or relative offset in the stream to move to
seekOrigin - on of three possible seek origins:
(offset <= 0).
Returns:
new absolute position in the stream.
Throws:
SevenZipException - in error case. If this method ends with an exception, the current operation will be reported to 7-Zip as failed. There are no guarantee, that there are no further call back methods will get called. The first and last thrown exceptions will be saved and thrown later on from the originally called method such as ISevenZipInArchive.extract() or SevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. See SevenZipException and SevenZipException.printStackTraceExtended() for details.

read

public int read(byte[] data)
         throws SevenZipException
$Reads at least 1 and maximum data.length bytes from the in-stream. If data.length == 0 0 should be returned. If data.length != 0, then return value 0 indicates end-of-stream (EOF). This means no more bytes can be read from the stream.
This function is allowed to read less than number of remaining bytes in stream and less then data.length. You must call read() function in loop, if you need exact amount of data.

Note: depending on the archive format and the data size this method may be called from different threads. Synchronized implementation may be required.

Specified by:
read in interface ISequentialInStream
Parameters:
data - buffer to get read data
Returns:
amount of bytes written in the data array. 0 - represents end of stream.
Throws:
SevenZipException - in error case. If this method ends with an exception, the current operation will be reported to 7-Zip as failed. There are no guarantee, that there are no further call back methods will get called. The first and last thrown exceptions will be saved and thrown later on from the originally called method such as ISevenZipInArchive.extract() or SevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. See SevenZipException and SevenZipException.printStackTraceExtended() for details.

close

public void close()
           throws java.io.IOException
Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException