Class JarHandler
- java.lang.Object
-
- net.ssehub.easy.instantiation.core.model.defaultInstantiators.ZipHandler
-
- net.ssehub.easy.instantiation.java.instantiators.JarHandler
-
public class JarHandler extends ZipHandler
A ZIP handler for JAR files.- Author:
- Holger Eichelberger
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.jar.ManifestlastOpenedManifestprivate java.io.Filemanifestprivate booleanunpackManifest
-
Constructor Summary
Constructors Constructor Description JarHandler()Creates a JAR handler for a JAR with default manifest and without manifest unpacking.JarHandler(boolean unpackManifest)Creates a JAR handler for a JAR with default manifest.JarHandler(java.io.File manifest, boolean unpackManifest)Creates a JAR handler for a given manifest file.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidadditionalUnpacking(java.util.zip.ZipInputStream zis, java.io.File target, java.util.List<java.io.File> files)Performs additional unpacking (called byZipHandler.unpack(File, File, String, List)).protected java.util.zip.ZipEntrycreateEntry(java.lang.String name, java.io.File file)Creates a ZIP entry.protected java.util.jar.JarInputStreamcreateInputStream(java.io.InputStream in)Creates a ZIP input stream forin.protected java.util.jar.JarOutputStreamcreateOutputStream(java.io.OutputStream out)Creates a ZIP output stream forout.protected booleaninclude(java.io.File file)Returns whetherfileshall be included in repackaging a JAR file.-
Methods inherited from class net.ssehub.easy.instantiation.core.model.defaultInstantiators.ZipHandler
add, unpack
-
-
-
-
Constructor Detail
-
JarHandler
public JarHandler()
Creates a JAR handler for a JAR with default manifest and without manifest unpacking.
-
JarHandler
public JarHandler(boolean unpackManifest)
Creates a JAR handler for a JAR with default manifest.- Parameters:
unpackManifest- whether the manifest shall be unpacked
-
JarHandler
public JarHandler(java.io.File manifest, boolean unpackManifest)Creates a JAR handler for a given manifest file.- Parameters:
manifest- the manifest (may be null for a default manifest or one taken from the underlying existing JAR file)unpackManifest- whether the manifest shall be unpacked
-
-
Method Detail
-
createInputStream
protected java.util.jar.JarInputStream createInputStream(java.io.InputStream in) throws java.io.IOExceptionDescription copied from class:ZipHandlerCreates a ZIP input stream forin. This method shall be overridden for specialized ZIP types, e.g., JAR.- Overrides:
createInputStreamin classZipHandler- Parameters:
in- the input stream to create the ZIP stream for.- Returns:
- the ZIP input stream
- Throws:
java.io.IOException- in case that creating the input stream fails
-
createOutputStream
protected java.util.jar.JarOutputStream createOutputStream(java.io.OutputStream out) throws java.io.IOExceptionDescription copied from class:ZipHandlerCreates a ZIP output stream forout. This method shall be overridden for specialized ZIP types, e.g., JAR.- Overrides:
createOutputStreamin classZipHandler- Parameters:
out- the output stream to create the ZIP stream for.- Returns:
- the ZIP output stream
- Throws:
java.io.IOException- in case that creating the output stream fails
-
createEntry
protected java.util.zip.ZipEntry createEntry(java.lang.String name, java.io.File file)Description copied from class:ZipHandlerCreates a ZIP entry. This method shall be overridden for specialized ZIP types, e.g., JAR.- Overrides:
createEntryin classZipHandler- Parameters:
name- the name of the entryfile- the underlying file- Returns:
- the ZIP entry
-
include
protected boolean include(java.io.File file)
Description copied from class:ZipHandlerReturns whetherfileshall be included in repackaging a JAR file.- Overrides:
includein classZipHandler- Parameters:
file- the file to be considered- Returns:
trueiffileshall be packed,falseelse
-
additionalUnpacking
protected void additionalUnpacking(java.util.zip.ZipInputStream zis, java.io.File target, java.util.List<java.io.File> files) throws java.io.IOExceptionDescription copied from class:ZipHandlerPerforms additional unpacking (called byZipHandler.unpack(File, File, String, List)).- Overrides:
additionalUnpackingin classZipHandler- Parameters:
zis- the ZIP input streamtarget- the target directory where to unpack (a temporary directory is created iftargetis null)files- the unpacked files (may contain directories, modified as a side effect, may be null if the unpacked files shall not be collected)- Throws:
java.io.IOException- in case that unpacking fails for some reason
-
-