Package net.sf.sevenzipjbinding
Interface IOutCreateCallback<T extends IOutItemBase>
- Type Parameters:
T- the type of the corresponding archive item data class (out item), likeIOutItem7zorIOutItemZip. UseIOutItemAllFormatsinterface to support all available archive formats.
- All Superinterfaces:
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 TypeMethodDescriptiongetItemInformation(int index, OutItemFactory<T> outItemFactory) Get information about archive item with indexindexbeing created or updated.getStream(int index) Return sequential in-stream for the archive item with indexindexto read and compress the content of the item.voidsetOperationResult(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
Notify about success or failure of the current archive item compression or update operation.- Parameters:
operationResultOk-truecurrent archive item was processed successfully,falseotherwise.- 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 asIInArchive.extract()orSevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. SeeSevenZipExceptionandSevenZipException.printStackTraceExtended()for details.
-
getItemInformation
Get information about archive item with indexindexbeing 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 byIOutItemBase.getIndex()of theoutItemobject.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 indexindex- Returns:
- data object created with the
outItemFactoryfilled 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 asIInArchive.extract()orSevenZip.openInArchive(). Up to four exceptions depending on the situation can be saved for further analysis. SeeSevenZipExceptionandSevenZipException.printStackTraceExtended()for details.
- New item within a create or an update operation:
-
getStream
Return sequential in-stream for the archive item with indexindexto read and compress the content of the item. Depending on the archive format, this method may be called for any archive item including directories.nullshould 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. Returnnullfor archive items without content (for example, for directories) - Throws:
SevenZipException- 7-Zip or 7-Zip-JBinding error occurs. UseSevenZipException.printStackTraceExtended()to get the stack traces of this SevenZipException and of all thrown 'caused by' exceptions.
-