13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
+
16
17
package org .metafacture .io ;
17
18
18
- import java .io .BufferedInputStream ;
19
- import java .io .BufferedOutputStream ;
20
- import java .io .InputStream ;
21
- import java .io .OutputStream ;
19
+ import org .metafacture .framework .MetafactureException ;
22
20
23
21
import org .apache .commons .compress .compressors .CompressorException ;
24
22
import org .apache .commons .compress .compressors .CompressorStreamFactory ;
25
23
import org .apache .commons .io .FilenameUtils ;
26
24
import org .apache .commons .io .input .ProxyInputStream ;
27
25
import org .apache .commons .io .output .ProxyOutputStream ;
28
- import org .metafacture .framework .MetafactureException ;
26
+
27
+ import java .io .BufferedInputStream ;
28
+ import java .io .BufferedOutputStream ;
29
+ import java .io .InputStream ;
30
+ import java .io .OutputStream ;
29
31
30
32
/**
31
33
* Provides a convenient interface for using stream compressors
@@ -61,15 +63,20 @@ public OutputStream createCompressor(final OutputStream writeTo, final String fi
61
63
final FileCompression compressor ;
62
64
if ("gz" .equalsIgnoreCase (extension )) {
63
65
compressor = GZIP ;
64
- } else if ("gzip" .equalsIgnoreCase (extension )) {
66
+ }
67
+ else if ("gzip" .equalsIgnoreCase (extension )) {
65
68
compressor = GZIP ;
66
- } else if ("bz2" .equalsIgnoreCase (extension )) {
69
+ }
70
+ else if ("bz2" .equalsIgnoreCase (extension )) {
67
71
compressor = BZIP2 ;
68
- } else if ("bzip2" .equalsIgnoreCase (extension )) {
72
+ }
73
+ else if ("bzip2" .equalsIgnoreCase (extension )) {
69
74
compressor = BZIP2 ;
70
- } else if ("xz" .equalsIgnoreCase (extension )) {
75
+ }
76
+ else if ("xz" .equalsIgnoreCase (extension )) {
71
77
compressor = XZ ;
72
- } else {
78
+ }
79
+ else {
73
80
compressor = NONE ;
74
81
}
75
82
@@ -83,7 +90,8 @@ public InputStream createDecompressor(final InputStream readFrom, final boolean
83
90
return decompressConcatenated ?
84
91
APACHE_COMPRESSOR_FACTORY_DECOMPRESS_CONCATENATED .createCompressorInputStream (bufferedStream ) :
85
92
APACHE_COMPRESSOR_FACTORY_NO_DECOMPRESS_CONCATENATED .createCompressorInputStream (bufferedStream );
86
- } catch (CompressorException e ) {
93
+ }
94
+ catch (final CompressorException e ) {
87
95
return NONE .createDecompressor (bufferedStream , decompressConcatenated );
88
96
}
89
97
}
@@ -95,7 +103,8 @@ public OutputStream createCompressor(final OutputStream writeTo, final String fi
95
103
try {
96
104
return APACHE_COMPRESSOR_FACTORY .createCompressorOutputStream (
97
105
CompressorStreamFactory .BZIP2 , bufferStream (writeTo ));
98
- } catch (CompressorException e ) {
106
+ }
107
+ catch (final CompressorException e ) {
99
108
throw new MetafactureException (e );
100
109
}
101
110
}
@@ -105,7 +114,8 @@ public InputStream createDecompressor(final InputStream readFrom, final boolean
105
114
try {
106
115
return APACHE_COMPRESSOR_FACTORY .createCompressorInputStream (
107
116
CompressorStreamFactory .BZIP2 , bufferStream (readFrom ), decompressConcatenated );
108
- } catch (CompressorException e ) {
117
+ }
118
+ catch (final CompressorException e ) {
109
119
throw new MetafactureException (e );
110
120
}
111
121
}
@@ -117,7 +127,8 @@ public OutputStream createCompressor(final OutputStream writeTo, final String fi
117
127
try {
118
128
return APACHE_COMPRESSOR_FACTORY .createCompressorOutputStream (
119
129
CompressorStreamFactory .GZIP , bufferStream (writeTo ));
120
- } catch (CompressorException e ) {
130
+ }
131
+ catch (final CompressorException e ) {
121
132
throw new MetafactureException (e );
122
133
}
123
134
}
@@ -127,7 +138,8 @@ public InputStream createDecompressor(final InputStream readFrom, final boolean
127
138
try {
128
139
return APACHE_COMPRESSOR_FACTORY .createCompressorInputStream (
129
140
CompressorStreamFactory .GZIP , bufferStream (readFrom ), decompressConcatenated );
130
- } catch (CompressorException e ) {
141
+ }
142
+ catch (final CompressorException e ) {
131
143
throw new MetafactureException (e );
132
144
}
133
145
}
@@ -139,7 +151,8 @@ public OutputStream createCompressor(final OutputStream writeTo, final String fi
139
151
try {
140
152
return APACHE_COMPRESSOR_FACTORY .createCompressorOutputStream (
141
153
CompressorStreamFactory .PACK200 , bufferStream (writeTo ));
142
- } catch (CompressorException e ) {
154
+ }
155
+ catch (final CompressorException e ) {
143
156
throw new MetafactureException (e );
144
157
}
145
158
}
@@ -149,7 +162,8 @@ public InputStream createDecompressor(final InputStream readFrom, final boolean
149
162
try {
150
163
return APACHE_COMPRESSOR_FACTORY .createCompressorInputStream (
151
164
CompressorStreamFactory .PACK200 , bufferStream (readFrom ), decompressConcatenated );
152
- } catch (CompressorException e ) {
165
+ }
166
+ catch (final CompressorException e ) {
153
167
throw new MetafactureException (e );
154
168
}
155
169
}
@@ -161,7 +175,8 @@ public OutputStream createCompressor(final OutputStream writeTo, final String fi
161
175
try {
162
176
return APACHE_COMPRESSOR_FACTORY .createCompressorOutputStream (
163
177
CompressorStreamFactory .XZ , bufferStream (writeTo ));
164
- } catch (CompressorException e ) {
178
+ }
179
+ catch (final CompressorException e ) {
165
180
throw new MetafactureException (e );
166
181
}
167
182
}
@@ -171,7 +186,8 @@ public InputStream createDecompressor(final InputStream readFrom, final boolean
171
186
try {
172
187
return APACHE_COMPRESSOR_FACTORY .createCompressorInputStream (
173
188
CompressorStreamFactory .XZ , bufferStream (readFrom ), decompressConcatenated );
174
- } catch (CompressorException e ) {
189
+ }
190
+ catch (final CompressorException e ) {
175
191
throw new MetafactureException (e );
176
192
}
177
193
}
@@ -186,9 +202,9 @@ public InputStream createDecompressor(final InputStream readFrom, final boolean
186
202
187
203
private static final int BUFFER_SIZE = 8 * 1024 * 1024 ;
188
204
189
- public abstract OutputStream createCompressor (final OutputStream writeTo , final String fileName );
205
+ public abstract OutputStream createCompressor (OutputStream writeTo , String fileName );
190
206
191
- public abstract InputStream createDecompressor (final InputStream readFrom , final boolean decompressConcatenated );
207
+ public abstract InputStream createDecompressor (InputStream readFrom , boolean decompressConcatenated );
192
208
193
209
public InputStream createDecompressor (final InputStream readFrom ) {
194
210
return createDecompressor (readFrom , DEFAULT_DECOMPRESS_CONCATENATED );
0 commit comments