Class Expand


  • class Expand
    extends java.lang.Object
    Expand will unpack the given zip archive.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static int BUFFER_SIZE  
      private java.io.File dest
      destination directory
      private boolean overwrite
      if the unpackaging should get performed if the destination already exists.
      private java.io.File source
      Source file which should get expanded
    • Constructor Summary

      Constructors 
      Constructor Description
      Expand()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private void deleteFileOrDir​(java.io.File targetFile)
      small helper method who deletes the given directory or file.
      void execute()
      Actually perform the unpacking of the source archive into the destination directory.
      (package private) void expandFile​(java.io.File srcFile, java.io.File destination)
      It is intended to be overwritten when implementing an own unarchiver
      (package private) void extractFile​(java.io.File archive, java.io.File destDir, java.io.InputStream compressedInputStream, java.lang.String entryName, java.util.Date entryDate, boolean isDirectory)
      Extract a single ZipEntry.
      void setDest​(java.io.File destinationDirectory)
      Set the destination directory into which the archive should get expanded.
      void setOverwrite​(boolean overwrite)
      If the destination directory should get overwritten if the content already exists.
      void setSrc​(java.io.File sourceArchive)
      The zip archive which should get expanded.
      • Methods inherited from class java.lang.Object

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

      • source

        private java.io.File source
        Source file which should get expanded
      • dest

        private java.io.File dest
        destination directory
      • overwrite

        private boolean overwrite
        if the unpackaging should get performed if the destination already exists.
    • Constructor Detail

      • Expand

        Expand()
    • Method Detail

      • setSrc

        public void setSrc​(java.io.File sourceArchive)
        The zip archive which should get expanded.
        Parameters:
        sourceArchive -
      • setDest

        public void setDest​(java.io.File destinationDirectory)
        Set the destination directory into which the archive should get expanded. The directory will get created if it doesn't yet exist while executing the expand.
        Parameters:
        destinationDirectory -
      • setOverwrite

        public void setOverwrite​(boolean overwrite)
        If the destination directory should get overwritten if the content already exists. If false we will only overwrite if the local file or directory is older than the one in the archive.
        Parameters:
        overwrite -
      • execute

        public void execute()
                     throws java.lang.Exception
        Actually perform the unpacking of the source archive into the destination directory.
        Throws:
        java.lang.Exception
      • expandFile

        void expandFile​(java.io.File srcFile,
                        java.io.File destination)
                 throws java.lang.Exception

        It is intended to be overwritten when implementing an own unarchiver

        Note: we kept this protected method for the sake of backward compatibility!

        Parameters:
        srcFile - The source file.
        destination - The destination.
        Throws:
        java.lang.Exception - In case of failure.
      • extractFile

        void extractFile​(java.io.File archive,
                         java.io.File destDir,
                         java.io.InputStream compressedInputStream,
                         java.lang.String entryName,
                         java.util.Date entryDate,
                         boolean isDirectory)
                  throws java.lang.Exception
        Extract a single ZipEntry.

        Note: we kept this protected method for the sake of backward compatibility!

        Parameters:
        archive - the archive to unpack
        destDir - the destination dirctory
        compressedInputStream -
        entryName -
        entryDate -
        isDirectory -
        Throws:
        java.lang.Exception
      • deleteFileOrDir

        private void deleteFileOrDir​(java.io.File targetFile)
                              throws java.io.IOException
        small helper method who deletes the given directory or file.
        Parameters:
        targetFile -
        Throws:
        java.io.IOException