net.sf.sevenzipjbinding.IOutCreateCallback Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sevenzipjbinding Show documentation
Show all versions of sevenzipjbinding Show documentation
7-Zip-JBinding is a free cross-platform java binding of 7-Zip free compress/decompress library
(http://www.7-zip.org/, http://p7zip.sourceforge.net/)
package net.sf.sevenzipjbinding;
import net.sf.sevenzipjbinding.impl.OutItemFactory;
/**
* The interface designed to provide necessary information about new or updated archive items and to receive information
* about the progress of the operation.
*
* @param
* the type of the corresponding archive item data class (out item), like {@link IOutItem7z} or
* {@link IOutItemZip}. Use {@link IOutItemAllFormats} interface to support all available archive formats.
*
* @author Boris Brodski
* @since 9.20-2.00
*/
public interface IOutCreateCallback extends IProgress {
/**
* Notify about success or failure of the current archive item compression or update operation.
*
* @param 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 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
* {@link SevenZipException} and {@link SevenZipException#printStackTraceExtended()} for details.
*/
public void setOperationResult(boolean operationResultOk) 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{@code <}IOutItemZip{@code >} 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{@code <}IOutItemZip{@code >} 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{@code <}IOutItemZip{@code >} 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;
* }
*
*
*
*
* @param index
* 0-based index of the item to get data. Same index returned by {@link IOutItemBase#getIndex()} of the
* outItem
object.
* @param 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
* @return 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 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
* {@link SevenZipException} and {@link SevenZipException#printStackTraceExtended()} for details.
*/
public T getItemInformation(int index, OutItemFactory outItemFactory) throws SevenZipException;
/**
* Return sequential in-stream for the archive item with index index
to read and compress the content
* of the item. Depending on a archive format, this method may be called for any archive item including directories.
* null
should be returned for archive items without any content.
*
* @param index
* index of the item to read content of (starting from 0)
* @return 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 occur. Use {@link SevenZipException#printStackTraceExtended()} to get
* stack traces of this SevenZipException and of the all thrown 'cause by' exceptions.
*/
public ISequentialInStream getStream(int index) throws SevenZipException;
}