org.entityfs.util.jar
Class JarCreator

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

public class JarCreator
extends AbstractZipCreator<JarCreator>

The JarCreator creates a Jar archive using ZipEntryInfo objects returned from an iterator. An EntityIteratorToJarEntryInfoIteratorAdapter can be used to create ZipEntryInfo objects from entities returned from an entity iterator.

The JarCreator will lock files for reading as their contents are copied to the Jar archive.

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

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

If a META-INF/MANIFEST.MF file is copied from the sources, it is used as the manifest file of the Jar, unless another manifest is set with the setManifest(Manifest) method.

Since:
1.0
Author:
Karl Gustafsson
In_jar:
entityfs-util

Constructor Summary
JarCreator(Iterator<? extends ZipEntryInfo> itr, DirectoryView targetDir, String targetFileName)
          Create a JarCreator that uses the default ErrorHandlingStrategy.
JarCreator(Iterator<? extends ZipEntryInfo> itr, DirectoryView targetDir, String targetFileName, ErrorHandlingStrategy ehs)
          Create a JarCreator that uses the provided ErrorHandlingStrategy.
 
Method Summary
protected  ZipOutputStream createOutputStream(WritableFile f)
          Override the inherited method to open a JarOutputStream instead.
 Manifest getManifest()
           
 JarCreator setManifest(Manifest mf)
          Set the Jar file's manifest.
 
Methods inherited from class org.entityfs.util.zip.AbstractZipCreator
create, create, 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

JarCreator

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

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

JarCreator

public JarCreator(Iterator<? extends ZipEntryInfo> itr,
                  DirectoryView targetDir,
                  String targetFileName,
                  ErrorHandlingStrategy ehs)
Create a JarCreator that uses the provided ErrorHandlingStrategy.

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

setManifest

public JarCreator setManifest(Manifest mf)
Set the Jar file's manifest.

Parameters:
mf - The manifest.
Returns:
this.

getManifest

public Manifest getManifest()

createOutputStream

protected ZipOutputStream createOutputStream(WritableFile f)
                                      throws IOException
Override the inherited method to open a JarOutputStream instead.

Overrides:
createOutputStream in class AbstractZipCreator<JarCreator>
Returns:
A JarOutputStream.
Throws:
IOException