Package org.goots.exploder
Class Exploder
- java.lang.Object
-
- org.goots.exploder.Exploder
-
public class Exploder extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringARCHIVE_UNPACK_SUFFIXUse a unique suffix for unpacking archives.
-
Constructor Summary
Constructors Constructor Description Exploder()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ExploderdisableRecursion()This will disable recursive unpack.ExploderexcludeSuffix(String suffix)Register suffix to ignore when exploding the archive(s).Set<String>getSupportedSuffixes()voidunpack(File root)Unpacks the contents of the file/directory, decompressing and unarchiving recursively.voidunpack(String path)Unpacks the contents of the url/file/directory, decompressing and unarchiving recursively.voidunpack(ExploderFileProcessor processor, File root)Unpacks the contents of the file/directory, decompressing and unarchiving recursively.voidunpack(ExploderFileProcessor processor, URL url)Unpacks the contents of the remote file, decompressing and unarchiving recursively.ExploderuseTargetDirectory(File targetDirectory)This will configure the current instance to use the specified target directory and copy the target File to it prior to unpacking.ExploderuseTemporaryDirectory()This will configure the current instance to use a temporary directory to copy the target File to prior to unpacking.
-
-
-
Field Detail
-
ARCHIVE_UNPACK_SUFFIX
public static final String ARCHIVE_UNPACK_SUFFIX
Use a unique suffix for unpacking archives.
-
-
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 theExploderFileProcessoron 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.
-
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 FileProcessorurl- 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 FileProcessorroot- root file (or directory contents) to explode- Throws:
InternalException- if an error occurs.
-
-