Interface IInArchive

All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
InArchiveImpl

public interface IInArchive extends Closeable
This interface provides functionality to query archive and archive-item parameters, and to extract item content.

Standard way to get implementation is to use SevenZip.

The last call should be a call to the method close(). After this call no more methods should be called.
Since:
4.65-1
Author:
Boris Brodski
  • Method Details

    • close

      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 AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • getNumberOfItems

      int getNumberOfItems() throws SevenZipException
      Returns count of items in archive. Depending on archive type directories are considered to be items or not.
      Returns:
      count of items in archive
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • getProperty

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

      NOTE: Some properties may only be available after the extraction operation completes.
      Example: PACKED_SIZE of the LZMA archives.
      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 occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • getStringProperty

      String getStringProperty(int index, PropID propID) throws SevenZipException
      Return property content in human readable form. Example for PropID.ATTRIBUTES: D for a directory.
      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 occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • extract

      void extract(int[] indices, boolean testMode, IArchiveExtractCallback extractCallback) throws SevenZipException
      Extract archive items with indices indices.
      Note: passing a sorted indices array is more efficient. However, it is not recommended to manually sort the indices with something like Arrays.sort(int[]) unless you can do it faster than a generic sort algorithm: O(n*log(n)).
      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 occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • extractSlow

      ExtractOperationResult extractSlow(int index, ISequentialOutStream outStream) throws SevenZipException
      Extract one item from archive. Multiple calls of this method are inefficient for some archive types.
      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 occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • extractSlow

      ExtractOperationResult extractSlow(int index, ISequentialOutStream outStream, String password) throws SevenZipException
      Extract one item from archive. Multiple calls of this method are inefficient for some archive types.
      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 occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • getArchiveProperty

      Object getArchiveProperty(PropID propID) throws SevenZipException
      Get value of archive property propID.
      Parameters:
      propID - property to get value of
      Returns:
      value of archive property propID
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • getStringArchiveProperty

      String getStringArchiveProperty(PropID propID) throws SevenZipException
      Return property value in human readable form.
      Parameters:
      propID - property to return
      Returns:
      property propID of archive in human readable form.
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • getNumberOfProperties

      int getNumberOfProperties() throws SevenZipException
      Return count of properties of each archive item
      Returns:
      count of properties of each archive item
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • getPropertyInfo

      PropertyInfo getPropertyInfo(int index) throws SevenZipException
      Get information about archive item property with index index.
      Parameters:
      index - property index
      Returns:
      information about property of archive item
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
      See Also:
    • getNumberOfArchiveProperties

      int getNumberOfArchiveProperties() throws SevenZipException
      Get count of properties of archive
      Returns:
      count of properties of archive
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
    • getArchivePropertyInfo

      PropertyInfo getArchivePropertyInfo(int index) throws SevenZipException
      Get information about archive property with index index.
      Parameters:
      index - property index
      Returns:
      information about archive property
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
      See Also:
    • getSimpleInterface

      ISimpleInArchive getSimpleInterface()
      Return simple 7-Zip interface for the archive
      Returns:
      simple 7-Zip interface for the archive
    • getArchiveFormat

      ArchiveFormat getArchiveFormat()
      Return archive format of the opened archive.
      Returns:
      archive format of the opened archive
    • getConnectedOutArchive

      IOutUpdateArchive<IOutItemAllFormats> getConnectedOutArchive() throws SevenZipException
      Get an instance of IOutUpdateArchive connected to the current archive. This is a part of the archive-format-independent API. The new instance allows modification of the currently opened archive. Multiple calls of this method 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 gets closed. Calls to the Closeable.close() methods of such connected instances will be ignored.
      Returns:
      an instance of the IOutUpdateArchive interface
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
      Since:
      9.20-2.00
    • getConnectedOutArchive7z

      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 calls of this method 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 gets closed. Calls to the Closeable.close() methods of such connected instances will be ignored.
      Returns:
      an instance of the IOutUpdateArchive interface
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
      Since:
      9.20-2.00
    • getConnectedOutArchiveZip

      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 calls of this method 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 gets closed. Calls to the Closeable.close() methods of such connected instances will be ignored.
      Returns:
      an instance of the IOutUpdateArchive interface
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
      Since:
      9.20-2.00
    • getConnectedOutArchiveTar

      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 calls of this method 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 gets closed. Calls to the Closeable.close() methods of such connected instances will be ignored.
      Returns:
      an instance of the IOutUpdateArchive interface
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
      Since:
      9.20-2.00
    • getConnectedOutArchiveGZip

      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 calls of this method 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 gets closed. Calls to the Closeable.close() methods of such connected instances will be ignored.
      Returns:
      an instance of the IOutUpdateArchive interface
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
      Since:
      9.20-2.00
    • getConnectedOutArchiveBZip2

      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 calls of this method 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 gets closed. Calls to the Closeable.close() methods of such connected instances will be ignored.
      Returns:
      an instance of the IOutUpdateArchive interface
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
      Since:
      9.20-2.00
    • getConnectedOutArchiveXz

      IOutUpdateArchiveXz getConnectedOutArchiveXz() throws SevenZipException
      Get an instance of IOutUpdateArchiveXz 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 Xz archive. Multiple calls of this method return the same instance. Closing the returned instance of IOutUpdateArchiveXz isn't necessary, since it will be closed automatically. This happens when the parent instance of the IInArchive gets closed. Calls to the Closeable.close() methods of such connected instances will be ignored.
      Returns:
      an instance of the IOutUpdateArchive interface
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
      Since:
      23.01-2.2