Interface IOutCreateCallback<T extends IOutItemBase>

Type Parameters:
T - the type of the corresponding archive item data class (out item), like IOutItem7z or IOutItemZip. Use IOutItemAllFormats interface to support all available archive formats.
All Superinterfaces:
IProgress

public interface IOutCreateCallback<T extends IOutItemBase> extends IProgress
The interface designed to provide necessary information about new or updated archive items and to receive information about the progress of the operation.
Since:
9.20-2.00
Author:
Boris Brodski
  • Method Summary

    Modifier and Type
    Method
    Description
    getItemInformation(int index, OutItemFactory<T> outItemFactory)
    Get information about archive item with index index being created or updated.
    getStream(int index)
    Return sequential in-stream for the archive item with index index to read and compress the content of the item.
    void
    setOperationResult(boolean operationResultOk)
    Notify about success or failure of the current archive item compression or update operation.

    Methods inherited from interface net.sf.sevenzipjbinding.IProgress

    setCompleted, setTotal
  • Method Details

    • setOperationResult

      void setOperationResult(boolean operationResultOk) throws SevenZipException
      Notify about success or failure of the current archive item compression or update operation.
      Parameters:
      operationResultOk - true current archive item was processed successfully, false otherwise.
      Throws:
      SevenZipException - in error case. If this method ends with an exception, the current operation will be reported to 7-Zip as failed. There is no guarantee that no further callback methods will be called. The first and last thrown exceptions will be saved and thrown later on from the originally called method such as IInArchive.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.
    • getItemInformation

      T getItemInformation(int index, OutItemFactory<T> outItemFactory) throws SevenZipException
      Get information about archive item with index index being created or updated. Consider following cases:
      • New item within a create or an update operation:
         public IOutItemZip getItemInformation(int index, OutItemFactory<IOutItemZip> outItemFactory) throws SevenZipException {
             IOutItemZip outItem = outItemFactory.createOutItem(); 
         
             outItem.setDataSize(size);
             outItem.setPropertyPath("readme.txt");
             
             // Set all other required properties here
         
             return outItem;
         }
         
      • Item based on an existing item (update only)
         public IOutItemZip getItemInformation(int index, OutItemFactory<IOutItemZip> outItemFactory) throws SevenZipException {
         
             // Determine index of the corresponding existing item in the old archive (archive being updated)
             int oldIndex = ...;
             
             IOutItemZip outItem = outItemFactory.createOutItem(oldIndex); 
         
             outItem.setPropertyPath("readme.txt");
             // Set all other required properties here
         
             return outItem;
         }
         
      • Item based on an existing item and inheriting some or all properties (update only)
         public IOutItemZip getItemInformation(int index, OutItemFactory<IOutItemZip> outItemFactory) throws SevenZipException {
         
             // Determine index of the corresponding existing item in the old archive (archive being updated)
             int oldIndex = ...;
         
             IOutItemZip outItem = outItemFactory.createOutItemAndCloneProperties(oldIndex); 
         
             // Set some properties
             outItem.setPropertyAttributes(newAttributes);
             
             // Keep other properties unchanged
         
             return outItem;
         }
         
      Parameters:
      index - 0-based index of the item to get data. Same index returned by IOutItemBase.getIndex() of the outItem object.
      outItemFactory - a factory to create a pre-initialized instance of the data object. The created object should be filled with information about the archive item with index index
      Returns:
      data object created with the outItemFactory filled with all necessary information for the current operation
      Throws:
      SevenZipException - in error case. If this method ends with an exception, the current operation will be reported to 7-Zip as failed. There is no guarantee that no further callback methods will be called. The first and last thrown exceptions will be saved and thrown later on from the originally called method such as IInArchive.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.
    • getStream

      ISequentialInStream getStream(int index) throws SevenZipException
      Return sequential in-stream for the archive item with index index to read and compress the content of the item. Depending on the archive format, this method may be called for any archive item including directories. null should be returned for archive items without any content.
      Parameters:
      index - index of the item to read content of (starting from 0)
      Returns:
      sequential in-stream pointed to the content of the archive item with index index. Return null for archive items without content (for example, for directories)
      Throws:
      SevenZipException - 7-Zip or 7-Zip-JBinding error occurs. Use SevenZipException.printStackTraceExtended() to get the stack traces of this SevenZipException and of all thrown 'caused by' exceptions.