org.entityfs.util.zip
Class ZipCreator

java.lang.Object
  extended by org.entityfs.util.AbstractIteratorUtil
      extended by org.entityfs.util.zip.AbstractZipCreator<ZipCreator>
          extended by org.entityfs.util.zip.ZipCreator

public class ZipCreator
extends AbstractZipCreator<ZipCreator>

The ZipCreator creates a Zip archive using ZipEntryInfo objects returned from an iterator. An EntityIteratorToZipEntryInfoIteratorAdapter can be used to create ZipEntryInfo objects from entities returned from an entity iterator.

The ZipCreator will lock files for reading as their contents are copied to the Zip archive.

After creating a ZipCreator object, various Zip file properties can be set using the object's setter methods.

If no data is returned from the iterator, the Zip file is not created at all.

If you just want to create a Zip file containing the contents of a directory hierarchy, the ZipFiles.zip(DirectoryView, DirectoryView, String) method is easier to use than this object.

This class uses Java's ZipOutputStream for creating the Zip file. For more flexibility in the Zip file contents, use the Zip builder from the At4J project instead.

Since:
1.0
Author:
Karl Gustafsson
See Also:
CompoundZipEntryInfoProvider, ZipFiles.unzip(org.entityfs.ReadableFile, DirectoryView), ZipFiles.zip(DirectoryView, DirectoryView, String)

Constructor Summary
ZipCreator(Iterator<? extends ZipEntryInfo> itr, DirectoryView targetDirectory, String targetFileName)
          Create a ZipCreator that uses the default ErrorHandlingStrategy.
ZipCreator(Iterator<? extends ZipEntryInfo> itr, DirectoryView targetDirectory, String targetFileName, ErrorHandlingStrategy ehs)
          Create a ZipCreator that uses the supplied ErrorHandlingStrategy.
 
Method Summary
 
Methods inherited from class org.entityfs.util.zip.AbstractZipCreator
create, create, createOutputStream, createTargetFile, getTargetDirectory, getTargetFileName, getThis, setComment, setLevel, setMethod
 
Methods inherited from class org.entityfs.util.AbstractIteratorUtil
letErrorStrategyHandle, letErrorStrategyHandle, letErrorStrategyHandle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ZipCreator

public ZipCreator(Iterator<? extends ZipEntryInfo> itr,
                  DirectoryView targetDirectory,
                  String targetFileName)
Create a ZipCreator that uses the default ErrorHandlingStrategy.

Parameters:
itr - The iterator to get ZipEntryInfo objects from.
targetDirectory - The directory where the Zip file will be created.
targetFileName - The name of the Zip file.

ZipCreator

public ZipCreator(Iterator<? extends ZipEntryInfo> itr,
                  DirectoryView targetDirectory,
                  String targetFileName,
                  ErrorHandlingStrategy ehs)
Create a ZipCreator that uses the supplied ErrorHandlingStrategy.

Parameters:
itr - The iterator to get ZipEntryInfo objects from.
targetDirectory - The directory where the Zip file will be created.
targetFileName - The name of the Zip file.
ehs - The error handling strategy.