Package net.sf.basedb.util.zip
Interface FileUnpacker
- All Superinterfaces:
Plugin
- All Known Implementing Classes:
AbstractFileUnpacker
,Bzip2FileUnpacker
,GzipFileUnpacker
,TarFileUnpacker
,ZipFileUnpacker
This interface should be implemented by plugins that can unpack a single compressed
file into the BASE file system. The plugin may extend the
AbstractFileUnpacker
class which implements most of the
plugin specified parts, leaving only the actual unpacking to the subclass.
The file upload functionality checks all plugins that implement this interface to provide automatic unpacking of uploaded files without having to store them in a temporary place first.
- Version:
- 2.0
- Author:
- nicklas
- See Also:
- Last modified
- $Date: 2011-09-23 09:05:23 +0200 (fr, 23 sep 2011) $
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.sf.basedb.core.plugin.Plugin
Plugin.MainType
-
Method Summary
Modifier and TypeMethodDescriptionGet the file extensions that this unpacker supports.Get the name of the compressed file format this unpacker supports.Get the MIME type for the file formats this unpacker supports.int
unpack
(DbControl dc, Directory dir, InputStream in, File sourceFile, boolean overwrite, AbsoluteProgressReporter progress) Unpack the given input stream into a BASE directory.Methods inherited from interface net.sf.basedb.core.plugin.Plugin
done, getMainType, getPermissions, init, requiresConfiguration, run, supportsConfigurations
-
Method Details
-
getFormatName
String getFormatName()Get the name of the compressed file format this unpacker supports. For example: ZIP files -
getExtensions
Get the file extensions that this unpacker supports. For example [ zip, jar ].- Returns:
- A set containing file extensions (do not inlcude the dot)
-
getMimeTypes
Get the MIME type for the file formats this unpacker supports. For example [ application/zip, application/java-archive ].- Returns:
- A set containing MIME types
-
unpack
int unpack(DbControl dc, Directory dir, InputStream in, File sourceFile, boolean overwrite, AbsoluteProgressReporter progress) throws IOException, BaseException Unpack the given input stream into a BASE directory. If a source file is given it can be used as a template for setting certain properties on the unpcked files. SeePackUtil.copyProperties(File, File)
.- Parameters:
dc
- The DbControl to use for database accessdir
- The directory to unpack the files toin
- The input stream containing the packed datasourceFile
- The source packed file that the input stream is coming from or null if not knownoverwrite
- If existing files should be overwritten or ignoredprogress
- A optional progress reporter which expects the number of compressed bytes that has been uncompressed- Returns:
- The number of unpacked files
- Throws:
IOException
- If there is an error reading the input streamBaseException
- If there is another error- Since:
- 3.0
-