3568 |
18 Jul 07 |
martin |
1 |
/** |
3568 |
18 Jul 07 |
martin |
$Id$ |
3568 |
18 Jul 07 |
martin |
3 |
|
3675 |
16 Aug 07 |
jari |
Copyright (C) 2007 Nicklas Nordborg, Martin Svensson |
4889 |
06 Apr 09 |
nicklas |
Copyright (C) 2008 Jari Häkkinen |
3568 |
18 Jul 07 |
martin |
6 |
|
3568 |
18 Jul 07 |
martin |
This file is part of BASE - BioArray Software Environment. |
3568 |
18 Jul 07 |
martin |
Available at http://base.thep.lu.se/ |
3568 |
18 Jul 07 |
martin |
9 |
|
3568 |
18 Jul 07 |
martin |
BASE is free software; you can redistribute it and/or modify it |
3568 |
18 Jul 07 |
martin |
under the terms of the GNU General Public License as published by |
4479 |
05 Sep 08 |
jari |
the Free Software Foundation; either version 3 of the License, or |
3568 |
18 Jul 07 |
martin |
(at your option) any later version. |
3568 |
18 Jul 07 |
martin |
14 |
|
3568 |
18 Jul 07 |
martin |
BASE is distributed in the hope that it will be useful, but |
3568 |
18 Jul 07 |
martin |
WITHOUT ANY WARRANTY; without even the implied warranty of |
3568 |
18 Jul 07 |
martin |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
3568 |
18 Jul 07 |
martin |
General Public License for more details. |
3568 |
18 Jul 07 |
martin |
19 |
|
3568 |
18 Jul 07 |
martin |
You should have received a copy of the GNU General Public License |
4515 |
11 Sep 08 |
jari |
along with BASE. If not, see <http://www.gnu.org/licenses/>. |
3568 |
18 Jul 07 |
martin |
22 |
*/ |
3568 |
18 Jul 07 |
martin |
23 |
|
3568 |
18 Jul 07 |
martin |
24 |
package net.sf.basedb.util.zip; |
3568 |
18 Jul 07 |
martin |
25 |
|
3568 |
18 Jul 07 |
martin |
26 |
import java.io.IOException; |
3641 |
08 Aug 07 |
nicklas |
27 |
import java.io.InputStream; |
3568 |
18 Jul 07 |
martin |
28 |
import java.io.OutputStream; |
3568 |
18 Jul 07 |
martin |
29 |
|
8094 |
04 Nov 22 |
nicklas |
30 |
import net.sf.basedb.core.PluginParameter; |
8094 |
04 Nov 22 |
nicklas |
31 |
import net.sf.basedb.core.StringParameterType; |
8094 |
04 Nov 22 |
nicklas |
32 |
|
3568 |
18 Jul 07 |
martin |
33 |
/** |
3641 |
08 Aug 07 |
nicklas |
This interface should be implemented by classes that can pack files and directories |
4483 |
07 Sep 08 |
jari |
from BASE file system. The implementing class must also have a public no-argument |
3641 |
08 Aug 07 |
nicklas |
constructor. The implementing classes are used by the |
3641 |
08 Aug 07 |
nicklas |
{@link net.sf.basedb.plugins.PackedFileExporter} plug-in. Each class should |
3641 |
08 Aug 07 |
nicklas |
be registered in a {@link net.sf.basedb.core.PluginConfiguration} for the |
3641 |
08 Aug 07 |
nicklas |
<code>PackedFileExporter</code>. |
3641 |
08 Aug 07 |
nicklas |
40 |
|
3641 |
08 Aug 07 |
nicklas |
@author Martin, Nicklas |
3568 |
18 Jul 07 |
martin |
@version 2.4 |
3568 |
18 Jul 07 |
martin |
@base.modified $Date: 2006-11-30 10:50:05 +0100 (Thu, 30 Nov 2006) $ |
3641 |
08 Aug 07 |
nicklas |
44 |
*/ |
3568 |
18 Jul 07 |
martin |
45 |
public interface FilePacker |
7551 |
12 Dec 18 |
nicklas |
46 |
extends AutoCloseable |
3568 |
18 Jul 07 |
martin |
47 |
{ |
3641 |
08 Aug 07 |
nicklas |
48 |
|
3568 |
18 Jul 07 |
martin |
49 |
/** |
3641 |
08 Aug 07 |
nicklas |
Get a short description of this file format that is suitable for display in |
3641 |
08 Aug 07 |
nicklas |
selection list boxes. |
3568 |
18 Jul 07 |
martin |
52 |
*/ |
3641 |
08 Aug 07 |
nicklas |
53 |
public String getDescription(); |
3641 |
08 Aug 07 |
nicklas |
54 |
|
3641 |
08 Aug 07 |
nicklas |
55 |
/** |
3641 |
08 Aug 07 |
nicklas |
Gets the extension that files, packed with this tool, should have, |
3641 |
08 Aug 07 |
nicklas |
for example, <code>zip</code> or <code>tar.gz</code> Don't include the first |
3641 |
08 Aug 07 |
nicklas |
dot! |
3641 |
08 Aug 07 |
nicklas |
@return A String with the file extension excluding the dot |
3641 |
08 Aug 07 |
nicklas |
60 |
*/ |
3568 |
18 Jul 07 |
martin |
61 |
public String getFileExtension(); |
3568 |
18 Jul 07 |
martin |
62 |
|
3568 |
18 Jul 07 |
martin |
63 |
/** |
3641 |
08 Aug 07 |
nicklas |
Gets the MIME type to give compressed files from this packer |
3641 |
08 Aug 07 |
nicklas |
@return The MIME type of the compressed file format |
3641 |
08 Aug 07 |
nicklas |
66 |
*/ |
3568 |
18 Jul 07 |
martin |
67 |
public String getMimeType(); |
3568 |
18 Jul 07 |
martin |
68 |
|
3568 |
18 Jul 07 |
martin |
69 |
/** |
8094 |
04 Nov 22 |
nicklas |
Does the packer support encryption or not? |
8094 |
04 Nov 22 |
nicklas |
The default implementation return false. |
8094 |
04 Nov 22 |
nicklas |
@since 3.19.5 |
8094 |
04 Nov 22 |
nicklas |
73 |
*/ |
8094 |
04 Nov 22 |
nicklas |
74 |
public default boolean supportsEncryption() |
8094 |
04 Nov 22 |
nicklas |
75 |
{ |
8094 |
04 Nov 22 |
nicklas |
76 |
return false; |
8094 |
04 Nov 22 |
nicklas |
77 |
} |
8094 |
04 Nov 22 |
nicklas |
78 |
|
8094 |
04 Nov 22 |
nicklas |
79 |
/** |
8094 |
04 Nov 22 |
nicklas |
The default implementation return a parameter asking for a password. |
8094 |
04 Nov 22 |
nicklas |
The implementing class may create another parameter as long as it is |
8094 |
04 Nov 22 |
nicklas |
named "password". This method is only called if the implementation |
8094 |
04 Nov 22 |
nicklas |
supports encryption. |
8094 |
04 Nov 22 |
nicklas |
@since 3.19.5 |
8094 |
04 Nov 22 |
nicklas |
85 |
*/ |
8094 |
04 Nov 22 |
nicklas |
86 |
public default PluginParameter<String> getPasswordParameter() |
8094 |
04 Nov 22 |
nicklas |
87 |
{ |
8094 |
04 Nov 22 |
nicklas |
88 |
PluginParameter<String> passwordParameter = new PluginParameter<String> |
8094 |
04 Nov 22 |
nicklas |
89 |
( |
8094 |
04 Nov 22 |
nicklas |
90 |
"password", "Password", "Enter a password to encrypt the archive." , new StringParameterType() |
8094 |
04 Nov 22 |
nicklas |
91 |
); |
8094 |
04 Nov 22 |
nicklas |
92 |
return passwordParameter; |
8094 |
04 Nov 22 |
nicklas |
93 |
} |
8094 |
04 Nov 22 |
nicklas |
94 |
|
8094 |
04 Nov 22 |
nicklas |
95 |
/** |
8094 |
04 Nov 22 |
nicklas |
Set the password to use for encrypting the archive. This method |
8094 |
04 Nov 22 |
nicklas |
is only called if the implementation supports encryption and the |
8094 |
04 Nov 22 |
nicklas |
user has entered a password. |
8094 |
04 Nov 22 |
nicklas |
@since 3.19.5 |
8094 |
04 Nov 22 |
nicklas |
100 |
*/ |
8094 |
04 Nov 22 |
nicklas |
101 |
public default void setPassword(String password) |
8094 |
04 Nov 22 |
nicklas |
102 |
{} |
8094 |
04 Nov 22 |
nicklas |
103 |
|
8094 |
04 Nov 22 |
nicklas |
104 |
/** |
3641 |
08 Aug 07 |
nicklas |
The output stream that the compressed files should be written to. |
3641 |
08 Aug 07 |
nicklas |
@param out The output stream to write to |
3641 |
08 Aug 07 |
nicklas |
@throws IOException If there is an error setting the output stream |
3641 |
08 Aug 07 |
nicklas |
108 |
*/ |
3641 |
08 Aug 07 |
nicklas |
109 |
public void setOutputStream(OutputStream out) |
3641 |
08 Aug 07 |
nicklas |
110 |
throws IOException; |
3568 |
18 Jul 07 |
martin |
111 |
|
3568 |
18 Jul 07 |
martin |
112 |
/** |
3641 |
08 Aug 07 |
nicklas |
Compress the uncompressed input stream to an entry with the given |
3641 |
08 Aug 07 |
nicklas |
name into the outputstream. |
3643 |
08 Aug 07 |
nicklas |
@param entryName The name of the packed resource, including path |
3643 |
08 Aug 07 |
nicklas |
information |
3641 |
08 Aug 07 |
nicklas |
@param in The input stream to read uncompressed data from, or null |
3641 |
08 Aug 07 |
nicklas |
if the entry represents a directory |
3641 |
08 Aug 07 |
nicklas |
@param size The number of bytes of uncompressed data |
3641 |
08 Aug 07 |
nicklas |
@param lastModified The time the contents was last modified, or 0 |
3641 |
08 Aug 07 |
nicklas |
if not known |
3641 |
08 Aug 07 |
nicklas |
@throws IOException If there are any errors when reading or writing |
3641 |
08 Aug 07 |
nicklas |
123 |
*/ |
3641 |
08 Aug 07 |
nicklas |
124 |
public void pack(String entryName, InputStream in, long size, long lastModified) |
3568 |
18 Jul 07 |
martin |
125 |
throws IOException; |
3641 |
08 Aug 07 |
nicklas |
126 |
|
3641 |
08 Aug 07 |
nicklas |
127 |
/** |
3646 |
09 Aug 07 |
nicklas |
End the packing and close. The plug-in should close any open resources, including |
3646 |
09 Aug 07 |
nicklas |
the output stream set by the {@link #setOutputStream(OutputStream)} method, and |
3646 |
09 Aug 07 |
nicklas |
cleanup temporary objects. |
3641 |
08 Aug 07 |
nicklas |
131 |
|
3641 |
08 Aug 07 |
nicklas |
@throws IOException If there are any errors |
3641 |
08 Aug 07 |
nicklas |
133 |
*/ |
7551 |
12 Dec 18 |
nicklas |
134 |
@Override |
3641 |
08 Aug 07 |
nicklas |
135 |
public void close() |
3641 |
08 Aug 07 |
nicklas |
136 |
throws IOException; |
3568 |
18 Jul 07 |
martin |
137 |
} |