Class DefaultJarArchive

    • Constructor Detail

      • DefaultJarArchive

        public DefaultJarArchive​(String file)
        Constructor.
        Parameters:
        file - The archive file
      • DefaultJarArchive

        public DefaultJarArchive​(InputStream inputStream)
                          throws IOException
        Constructor.
        Parameters:
        inputStream - The input stream for the archive (it will be closed after the constructor returns)
        Throws:
        IOException - If there was a problem reading the WAR
    • Method Detail

      • getFileHandler

        public FileHandler getFileHandler()
        Returns:
        the file utility class to use for performing all file I/O.
      • setFileHandler

        public void setFileHandler​(FileHandler fileHandler)
        Parameters:
        fileHandler - the file utility class to use for performing all file I/O.
      • containsClass

        public boolean containsClass​(String className)
                              throws IOException
        Returns whether a class of the specified name is contained in the archive.
        Specified by:
        containsClass in interface JarArchive
        Parameters:
        className - The name of the class to search for
        Returns:
        Whether the class was found
        Throws:
        IOException - If an I/O error occurred reading the archive
      • findResource

        public String findResource​(String name)
                            throws IOException
        Returns the full path of a named resource in the archive.
        Specified by:
        findResource in interface JarArchive
        Parameters:
        name - The name of the resource
        Returns:
        The full path to the resource inside the archive
        Throws:
        IOException - If an I/O error occurred reading the archive
      • getResource

        public InputStream getResource​(String path)
                                throws IOException
        Returns a resource from the archive as input stream.
        Specified by:
        getResource in interface JarArchive
        Parameters:
        path - The path to the resource in the archive
        Returns:
        An input stream containing the specified resource, or null if the resource was not found in the JAR
        Throws:
        IOException - If an I/O error occurs
      • getResources

        public List<String> getResources​(String path)
                                  throws IOException
        Returns the list of resources in the specified directory in the archive.
        Specified by:
        getResources in interface JarArchive
        Parameters:
        path - The directory
        Returns:
        The list of resources
        Throws:
        IOException - If an I/O error occurs
      • getContentAsStream

        protected final JarInputStream getContentAsStream()
                                                   throws IOException
        Returns the content of the archive as JarInputStream.
        Returns:
        The input stream
        Throws:
        IOException - If an exception occurred reading the archive
      • expandToPath

        public void expandToPath​(String path)
                          throws IOException
        Expand the archive to the specified directory.
        Specified by:
        expandToPath in interface JarArchive
        Parameters:
        path - The path to expand to
        Throws:
        IOException - If an I/O error occurs
      • expandToPath

        public void expandToPath​(String path,
                                 FileFilter filter)
                          throws IOException
        Expand the archive to the specified directory, filtering out files.
        Specified by:
        expandToPath in interface JarArchive
        Parameters:
        path - The path to expand to
        filter - The filter to use
        Throws:
        IOException - If an I/O error occurs
      • streamToByteArray

        protected byte[] streamToByteArray​(InputStream inputStream)
                                    throws IOException
        Read a stream into a byte array.
        Parameters:
        inputStream - the input stream
        Returns:
        the byte array
        Throws:
        IOException - if an IO Exception