Class JarHandler


  • public class JarHandler
    extends ZipHandler
    A ZIP handler for JAR files.
    Author:
    Holger Eichelberger
    • 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 void additionalUnpacking​(java.util.zip.ZipInputStream zis, java.io.File target, java.util.List<java.io.File> files)
      Performs additional unpacking (called by ZipHandler.unpack(File, File, String, List)).
      protected java.util.zip.ZipEntry createEntry​(java.lang.String name, java.io.File file)
      Creates a ZIP entry.
      protected java.util.jar.JarInputStream createInputStream​(java.io.InputStream in)
      Creates a ZIP input stream for in.
      protected java.util.jar.JarOutputStream createOutputStream​(java.io.OutputStream out)
      Creates a ZIP output stream for out.
      protected boolean include​(java.io.File file)
      Returns whether file shall be included in repackaging a JAR file.
      • Methods inherited from class net.ssehub.easy.instantiation.core.model.defaultInstantiators.ZipHandler

        add, unpack
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • lastOpenedManifest

        private java.util.jar.Manifest lastOpenedManifest
      • manifest

        private java.io.File manifest
      • unpackManifest

        private boolean unpackManifest
    • 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.IOException
        Description copied from class: ZipHandler
        Creates a ZIP input stream for in. This method shall be overridden for specialized ZIP types, e.g., JAR.
        Overrides:
        createInputStream in class ZipHandler
        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.IOException
        Description copied from class: ZipHandler
        Creates a ZIP output stream for out. This method shall be overridden for specialized ZIP types, e.g., JAR.
        Overrides:
        createOutputStream in class ZipHandler
        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: ZipHandler
        Creates a ZIP entry. This method shall be overridden for specialized ZIP types, e.g., JAR.
        Overrides:
        createEntry in class ZipHandler
        Parameters:
        name - the name of the entry
        file - the underlying file
        Returns:
        the ZIP entry
      • include

        protected boolean include​(java.io.File file)
        Description copied from class: ZipHandler
        Returns whether file shall be included in repackaging a JAR file.
        Overrides:
        include in class ZipHandler
        Parameters:
        file - the file to be considered
        Returns:
        true if file shall be packed, false else
      • additionalUnpacking

        protected void additionalUnpacking​(java.util.zip.ZipInputStream zis,
                                           java.io.File target,
                                           java.util.List<java.io.File> files)
                                    throws java.io.IOException
        Description copied from class: ZipHandler
        Performs additional unpacking (called by ZipHandler.unpack(File, File, String, List)).
        Overrides:
        additionalUnpacking in class ZipHandler
        Parameters:
        zis - the ZIP input stream
        target - the target directory where to unpack (a temporary directory is created if target is 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