Class Exploder


  • public class Exploder
    extends Object
    • Field Detail

      • ARCHIVE_UNPACK_SUFFIX

        public static final String ARCHIVE_UNPACK_SUFFIX
        Use a unique suffix for unpacking archives.
    • Constructor Detail

      • Exploder

        public Exploder()
    • Method Detail

      • excludeSuffix

        public Exploder excludeSuffix​(String suffix)
                               throws InternalException
        Register suffix to ignore when exploding the archive(s).
        Parameters:
        suffix - the suffix to ignore e.g. .jar
        Returns:
        the current Exploder instance.
        Throws:
        InternalException - if an error occurs.
      • disableRecursion

        public Exploder disableRecursion()
        This will disable recursive unpack. By default Exploder will recursively unpack all supported types.
        Returns:
        the current Exploder instance.
      • useTemporaryDirectory

        public Exploder useTemporaryDirectory()
                                       throws InternalException
        This will configure the current instance to use a temporary directory to copy the target File to prior to unpacking. This is useful if running the ExploderFileProcessor on an archive. This WILL delete the temporary directory on completion.
        Returns:
        the current Exploder instance.
        Throws:
        InternalException - if an error occurs.
      • useTargetDirectory

        public Exploder useTargetDirectory​(File targetDirectory)
                                    throws InternalException
        This will configure the current instance to use the specified target directory and copy the target File to it prior to unpacking. It will NOT delete the working directory on completion.
        Parameters:
        targetDirectory - the specified target directory to configure.
        Returns:
        the current Exploder instance.
        Throws:
        InternalException - if an error occurs.
      • getSupportedSuffixes

        public Set<String> getSupportedSuffixes()
      • unpack

        public void unpack​(String path)
                    throws InternalException
        Unpacks the contents of the url/file/directory, decompressing and unarchiving recursively. This is a simple wrapper around the File/URL methods.
        Parameters:
        path - root url, file (or directory contents) to explode
        Throws:
        InternalException - if an error occurs.
      • unpack

        public void unpack​(ExploderFileProcessor processor,
                           URL url)
                    throws InternalException
        Unpacks the contents of the remote file, decompressing and unarchiving recursively. It will use the specified ExploderFileProcessor on each target file. If a temporary or working directory has not been configured then this will implicitly create and use a temporary directory which WILL be cleaned up.
        Parameters:
        processor - the optional FileProcessor
        url - remote file to explode
        Throws:
        InternalException - if an error occurs.
      • unpack

        public void unpack​(File root)
                    throws InternalException
        Unpacks the contents of the file/directory, decompressing and unarchiving recursively. If a root is a directory then it will copy the it to the target directory first. If a temporary directory has been configured it will be cleaned up at the end.
        Parameters:
        root - root file (or directory contents) to explode
        Throws:
        InternalException - if an error occurs.
      • unpack

        public void unpack​(ExploderFileProcessor processor,
                           File root)
                    throws InternalException
        Unpacks the contents of the file/directory, decompressing and unarchiving recursively. It will use the specified ExploderFileProcessor on each target file. If a root is a directory then it will copy the it to the target directory first. If a temporary directory has been configured it will be cleaned up at the end.
        Parameters:
        processor - the optional FileProcessor
        root - root file (or directory contents) to explode
        Throws:
        InternalException - if an error occurs.