net.sf.sevenzipjbinding.impl
Class OutArchiveImpl<T extends IOutItemBase>

java.lang.Object
  extended by net.sf.sevenzipjbinding.impl.OutArchiveImpl<T>
Type Parameters:
T - the type of the item callback implementation
All Implemented Interfaces:
java.io.Closeable, IOutArchive<T>, IOutArchiveBase, IOutCreateArchive<T>, IOutUpdateArchive<T>
Direct Known Subclasses:
OutArchive7zImpl, OutArchiveBZip2Impl, OutArchiveGZipImpl, OutArchiveTarImpl, OutArchiveZipImpl

public class OutArchiveImpl<T extends IOutItemBase>
extends java.lang.Object
implements IOutArchive<T>

Common archive create and update class.

Since:
9.20-2.00
Author:
Boris Brodski
See Also:
OutArchive7zImpl, OutArchiveZipImpl, OutArchiveGZipImpl, OutArchiveBZip2Impl, OutArchiveTarImpl

Constructor Summary
OutArchiveImpl()
           
 
Method Summary
 void close()
          
 void createArchive(ISequentialOutStream outStream, int numberOfItems, IOutCreateCallback<? extends T> outCreateCallback)
          Create new archive.
 ArchiveFormat getArchiveFormat()
          Return archive format used with this instance of IOutStream
 IInArchive getConnectedInArchive()
          Get connected IInArchive for update operations.
 java.io.PrintStream getTracePrintStream()
          Alternative PrintStream for trace output.
 boolean isTrace()
          If true, print trace message during compress and update operation to the System.out or IOutArchiveBase.getTracePrintStream().
 void setTrace(boolean trace)
          If true, print trace message during compress and update operation to the System.out or IOutArchiveBase.getTracePrintStream().
 void setTracePrintStream(java.io.PrintStream tracePrintStream)
          Set alternative PrintStream for trace output.
 void updateItems(ISequentialOutStream outStream, int numberOfItems, IOutCreateCallback<T> outUpdateCallback)
          Update items in archive (actually creating a new one based on the old one).
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

OutArchiveImpl

public OutArchiveImpl()
Method Detail

getArchiveFormat

public ArchiveFormat getArchiveFormat()
Return archive format used with this instance of IOutStream

Specified by:
getArchiveFormat in interface IOutCreateArchive<T extends IOutItemBase>
Specified by:
getArchiveFormat in interface IOutUpdateArchive<T extends IOutItemBase>
Returns:
archive format used with this instance of IOutStream

close

public void close()
           throws java.io.IOException

Specified by:
close in interface java.io.Closeable
Throws:
java.io.IOException

updateItems

public void updateItems(ISequentialOutStream outStream,
                        int numberOfItems,
                        IOutCreateCallback<T> outUpdateCallback)
                 throws SevenZipException
Update items in archive (actually creating a new one based on the old one).

Specified by:
updateItems in interface IOutUpdateArchive<T extends IOutItemBase>
Parameters:
outStream - output stream to get the new archive
numberOfItems - number of items in the new archive
outUpdateCallback - create call back object to provide more information for archive update operation.
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.

createArchive

public void createArchive(ISequentialOutStream outStream,
                          int numberOfItems,
                          IOutCreateCallback<? extends T> outCreateCallback)
                   throws SevenZipException
Create new archive. To update an existing archive open it first and then use IInArchive.getConnectedOutArchive() to get an instance of the IOutUpdateArchive interface.

The outCreateCallback is designed to provide necessary information about new archive items and to receive information about the progress of the operation.

Note: some archive formats (like Zip) require an implementation of the IOutStream interface (instead of the ISequentialOutStream) to be passed.

Specified by:
createArchive in interface IOutCreateArchive<T extends IOutItemBase>
Parameters:
outStream - output stream to receive the new archive. An implementation of the IOutStream interface is required for some archive formats.
numberOfItems - number of items in the new archive
outCreateCallback - callback object to exchange information about the archive create operation.
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.

getConnectedInArchive

public IInArchive getConnectedInArchive()
Get connected IInArchive for update operations.

Specified by:
getConnectedInArchive in interface IOutUpdateArchive<T extends IOutItemBase>
Returns:
connected IInArchive for update operations

setTracePrintStream

public void setTracePrintStream(java.io.PrintStream tracePrintStream)
Set alternative PrintStream for trace output. Default: System.out.

Specified by:
setTracePrintStream in interface IOutArchiveBase
Parameters:
tracePrintStream - instance of the PrintStream.
See Also:
IOutArchiveBase.setTrace(boolean)

getTracePrintStream

public java.io.PrintStream getTracePrintStream()
Alternative PrintStream for trace output. Default: System.out.

Specified by:
getTracePrintStream in interface IOutArchiveBase
Returns:
Alternative PrintStream for trace output
See Also:
IOutArchiveBase.setTrace(boolean)

setTrace

public void setTrace(boolean trace)
If true, print trace message during compress and update operation to the System.out or IOutArchiveBase.getTracePrintStream(). Default: false

Specified by:
setTrace in interface IOutArchiveBase
Parameters:
trace - true - output trace messages, false be quite.
See Also:
IOutArchiveBase.setTracePrintStream(PrintStream)

isTrace

public boolean isTrace()
If true, print trace message during compress and update operation to the System.out or IOutArchiveBase.getTracePrintStream(). Default: false

Specified by:
isTrace in interface IOutArchiveBase
Returns:
true - output trace messages, false be quite.
See Also:
IOutArchiveBase.setTracePrintStream(PrintStream)