net.sf.sevenzipjbinding.impl
Class InArchiveImpl

java.lang.Object
  extended by net.sf.sevenzipjbinding.impl.InArchiveImpl
All Implemented Interfaces:
java.io.Closeable, IInArchive

public final class InArchiveImpl
extends java.lang.Object
implements IInArchive

Implementation of IInArchive.

Since:
4.65-1
Author:
Boris Brodski

Constructor Summary
InArchiveImpl()
           
 
Method Summary
 void close()
          Close archive.
 void extract(int[] indices, boolean testMode, IArchiveExtractCallback extractCallback)
          Extract archive items with indices indices.
 ExtractOperationResult extractSlow(int index, ISequentialOutStream outStream)
          Extract one item from archive.
 ExtractOperationResult extractSlow(int index, ISequentialOutStream outStream, java.lang.String password)
          Extract one item from archive.
 ArchiveFormat getArchiveFormat()
          $Return archive format of the opened archive.
 java.lang.Object getArchiveProperty(PropID propID)
          Get value of archive property propID.
 PropertyInfo getArchivePropertyInfo(int index)
          Get information about archive property with index index.
 IOutUpdateArchive<IOutItemAllFormats> getConnectedOutArchive()
          Get an instance of IOutUpdateArchive connected to the current archive.
 IOutUpdateArchive7z getConnectedOutArchive7z()
          Get an instance of IOutUpdateArchive7z connected to the current archive.
 IOutUpdateArchiveBZip2 getConnectedOutArchiveBZip2()
          Get an instance of IOutUpdateArchiveBZip2 connected to the current archive.
 IOutUpdateArchiveGZip getConnectedOutArchiveGZip()
          Get an instance of IOutUpdateArchiveGZip connected to the current archive.
 IOutUpdateArchiveTar getConnectedOutArchiveTar()
          Get an instance of IOutUpdateArchiveTar connected to the current archive.
 IOutUpdateArchiveZip getConnectedOutArchiveZip()
          Get an instance of IOutUpdateArchiveZip connected to the current archive.
 int getNumberOfArchiveProperties()
          Get count of properties of archive
 int getNumberOfItems()
          Returns count of items in archive.
 int getNumberOfProperties()
          Return count of properties of each archive item
 java.lang.Object getProperty(int index, PropID propID)
          Get value of property propID of the item with the index index.

NOTE: Some properties my only be available after the extraction operation completes.
Example: PACKED_SIZE of the LZMA archives.
 PropertyInfo getPropertyInfo(int index)
          Get information about archive item property with index index.
 ISimpleInArchive getSimpleInterface()
          Return simple 7-Zip interface for the archive
 java.lang.String getStringArchiveProperty(PropID propID)
          Return property value in human readable form.
 java.lang.String getStringProperty(int index, PropID propID)
          Return property content in human readable form.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InArchiveImpl

public InArchiveImpl()
Method Detail

extract

public void extract(int[] indices,
                    boolean testMode,
                    IArchiveExtractCallback extractCallback)
             throws SevenZipException
Extract archive items with indices indices.
Note: passing sorted indices array is more efficient. But it isn't suggested to manually sort indices with something like Arrays.sort(int[]). Sort indices only, if you can do it quicker, that generic sort algorithms: O(n*log(n)).

Specified by:
extract in interface IInArchive
Parameters:
indices - (optional) array of indices of archive items to extract.
null - all archive items.
testMode - true - test archive items only
false - extract archive items
extractCallback - extraction callback object. Optional implementation of ICryptoGetTextPassword.
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.

extractSlow

public ExtractOperationResult extractSlow(int index,
                                          ISequentialOutStream outStream)
                                   throws SevenZipException
Extract one item from archive. Multiple calls of this method are inefficient for some archive types.

Specified by:
extractSlow in interface IInArchive
Parameters:
index - index of the item to extract. 0 - first archive item.
outStream - sequential output stream to get content of the item
Returns:
result status of the extraction
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.

extractSlow

public ExtractOperationResult extractSlow(int index,
                                          ISequentialOutStream outStream,
                                          java.lang.String password)
                                   throws SevenZipException
Extract one item from archive. Multiple calls of this method are inefficient for some archive types.

Specified by:
extractSlow in interface IInArchive
Parameters:
index - index of the item to extract. 0 - first archive item.
outStream - sequential output stream to get content of the item
password - password to use
Returns:
result status of the extraction
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.

getArchiveProperty

public java.lang.Object getArchiveProperty(PropID propID)
                                    throws SevenZipException
Get value of archive property propID.

Specified by:
getArchiveProperty in interface IInArchive
Parameters:
propID - property to get value of
Returns:
value of archive property propID
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.

getStringArchiveProperty

public java.lang.String getStringArchiveProperty(PropID propID)
                                          throws SevenZipException
Return property value in human readable form.

Specified by:
getStringArchiveProperty in interface IInArchive
Parameters:
propID - property to return
Returns:
property propID of archive in human readable form.
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.

getArchivePropertyInfo

public PropertyInfo getArchivePropertyInfo(int index)
                                    throws SevenZipException
Get information about archive property with index index.

Specified by:
getArchivePropertyInfo in interface IInArchive
Parameters:
index - property index
Returns:
information about archive property
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.
See Also:
IInArchive.getNumberOfArchiveProperties()

getNumberOfArchiveProperties

public int getNumberOfArchiveProperties()
                                 throws SevenZipException
Get count of properties of archive

Specified by:
getNumberOfArchiveProperties in interface IInArchive
Returns:
count of properties 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.

getNumberOfProperties

public int getNumberOfProperties()
                          throws SevenZipException
Return count of properties of each archive item

Specified by:
getNumberOfProperties in interface IInArchive
Returns:
count of properties of each archive item
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.

getPropertyInfo

public PropertyInfo getPropertyInfo(int index)
                             throws SevenZipException
Get information about archive item property with index index.

Specified by:
getPropertyInfo in interface IInArchive
Parameters:
index - property index
Returns:
information about property of archive item
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.
See Also:
IInArchive.getNumberOfProperties()

close

public void close()
           throws SevenZipException
Close archive. This method should be the last one called on the implementation of this interface. After this call no more methods should be called.

Specified by:
close in interface java.io.Closeable
Specified by:
close in interface IInArchive
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.

getNumberOfItems

public int getNumberOfItems()
                     throws SevenZipException
Returns count of items in archive. Depending on archive type directories are considered to be items or not.

Specified by:
getNumberOfItems in interface IInArchive
Returns:
count of items in 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.

getProperty

public java.lang.Object getProperty(int index,
                                    PropID propID)
                             throws SevenZipException
Get value of property propID of the item with the index index.

NOTE: Some properties my only be available after the extraction operation completes.
Example: PACKED_SIZE of the LZMA archives.

Specified by:
getProperty in interface IInArchive
Parameters:
index - index of item to get property value. 0 - first archive item.
propID - property to get value of
Returns:
value of property propID of item with index index
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.

getStringProperty

public java.lang.String getStringProperty(int index,
                                          PropID propID)
                                   throws SevenZipException
Return property content in human readable form. Example for PropID.ATTRIBUTES: D for a directory.

Specified by:
getStringProperty in interface IInArchive
Parameters:
index - index of item in archive to get property of. 0 - first archive item.
propID - property to return
Returns:
property propID of item with id index in human readable form.
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.

getSimpleInterface

public ISimpleInArchive getSimpleInterface()
Return simple 7-Zip interface for the archive

Specified by:
getSimpleInterface in interface IInArchive
Returns:
simple 7-Zip interface for the archive

getArchiveFormat

public ArchiveFormat getArchiveFormat()
$Return archive format of the opened archive.

Specified by:
getArchiveFormat in interface IInArchive
Returns:
archive format of the opened archive

getConnectedOutArchive

public IOutUpdateArchive<IOutItemAllFormats> getConnectedOutArchive()
                                                             throws SevenZipException
Get an instance of IOutUpdateArchive connected to the current archive. This is a part of the archive format non-specific API. The new instance allows modification of the currently opened archive. Multiple call of this methods return the same instance. Closing the returned instance of IOutUpdateArchive isn't necessary, since it will be closed automatically. This happens when the parent instance of the IInArchive get closed. Calls to the Closeable.close() methods of such connected instances will be ignored.

Specified by:
getConnectedOutArchive in interface IInArchive
Returns:
an instance of the IOutUpdateArchive interface
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.

getConnectedOutArchive7z

public IOutUpdateArchive7z getConnectedOutArchive7z()
                                             throws SevenZipException
Get an instance of IOutUpdateArchive7z connected to the current archive. This is a part of the archive format specific API. The new instance only allows modification of the currently opened 7z archive. Multiple call of this methods return the same instance. Closing the returned instance of IOutUpdateArchive7z isn't necessary, since it will be closed automatically. This happens when the parent instance of the IInArchive get closed. Calls to the Closeable.close() methods of such connected instances will be ignored.

Specified by:
getConnectedOutArchive7z in interface IInArchive
Returns:
an instance of the IOutUpdateArchive interface
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.

getConnectedOutArchiveZip

public IOutUpdateArchiveZip getConnectedOutArchiveZip()
                                               throws SevenZipException
Get an instance of IOutUpdateArchiveZip connected to the current archive. This is a part of the archive format specific API. The new instance only allows modification of the currently opened Zip archive. Multiple call of this methods return the same instance. Closing the returned instance of IOutUpdateArchiveZip isn't necessary, since it will be closed automatically. This happens when the parent instance of the IInArchive get closed. Calls to the Closeable.close() methods of such connected instances will be ignored.

Specified by:
getConnectedOutArchiveZip in interface IInArchive
Returns:
an instance of the IOutUpdateArchive interface
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.

getConnectedOutArchiveTar

public IOutUpdateArchiveTar getConnectedOutArchiveTar()
                                               throws SevenZipException
Get an instance of IOutUpdateArchiveTar connected to the current archive. This is a part of the archive format specific API. The new instance only allows modification of the currently opened Tar archive. Multiple call of this methods return the same instance. Closing the returned instance of IOutUpdateArchiveTar isn't necessary, since it will be closed automatically. This happens when the parent instance of the IInArchive get closed. Calls to the Closeable.close() methods of such connected instances will be ignored.

Specified by:
getConnectedOutArchiveTar in interface IInArchive
Returns:
an instance of the IOutUpdateArchive interface
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.

getConnectedOutArchiveGZip

public IOutUpdateArchiveGZip getConnectedOutArchiveGZip()
                                                 throws SevenZipException
Get an instance of IOutUpdateArchiveGZip connected to the current archive. This is a part of the archive format specific API. The new instance only allows modification of the currently opened GZip archive. Multiple call of this methods return the same instance. Closing the returned instance of IOutUpdateArchiveGZip isn't necessary, since it will be closed automatically. This happens when the parent instance of the IInArchive get closed. Calls to the Closeable.close() methods of such connected instances will be ignored.

Specified by:
getConnectedOutArchiveGZip in interface IInArchive
Returns:
an instance of the IOutUpdateArchive interface
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.

getConnectedOutArchiveBZip2

public IOutUpdateArchiveBZip2 getConnectedOutArchiveBZip2()
                                                   throws SevenZipException
Get an instance of IOutUpdateArchiveBZip2 connected to the current archive. This is a part of the archive format specific API. The new instance only allows modification of the currently opened BZip2 archive. Multiple call of this methods return the same instance. Closing the returned instance of IOutUpdateArchiveBZip2 isn't necessary, since it will be closed automatically. This happens when the parent instance of the IInArchive get closed. Calls to the Closeable.close() methods of such connected instances will be ignored.

Specified by:
getConnectedOutArchiveBZip2 in interface IInArchive
Returns:
an instance of the IOutUpdateArchive interface
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.