~ubuntu-branches/ubuntu/utopic/libcommons-compress-java/utopic

« back to all changes in this revision

Viewing changes to src/main/java/org/apache/commons/compress/compressors/CompressorStreamFactory.java

  • Committer: Package Import Robot
  • Author(s): Emmanuel Bourg
  • Date: 2014-03-13 08:37:01 UTC
  • mfrom: (1.1.6)
  • Revision ID: package-import@ubuntu.com-20140313083701-spnlyo3fl3qcp0ab
Tags: 1.8-1
* New upstream release
* Updated the OSGi metadata
* The dependency on libxz-java is now suggested and no longer required

Show diffs side-by-side

added added

removed removed

Lines of Context:
32
32
import org.apache.commons.compress.compressors.xz.XZUtils;
33
33
import org.apache.commons.compress.compressors.pack200.Pack200CompressorInputStream;
34
34
import org.apache.commons.compress.compressors.pack200.Pack200CompressorOutputStream;
 
35
import org.apache.commons.compress.compressors.snappy.FramedSnappyCompressorInputStream;
 
36
import org.apache.commons.compress.compressors.snappy.SnappyCompressorInputStream;
 
37
import org.apache.commons.compress.compressors.z.ZCompressorInputStream;
35
38
import org.apache.commons.compress.utils.IOUtils;
36
39
 
37
40
/**
91
94
     */
92
95
    public static final String LZMA = "lzma";
93
96
 
 
97
    /**
 
98
     * Constant used to identify the "framed" Snappy compression method.
 
99
     * @since 1.7
 
100
     */
 
101
    public static final String SNAPPY_FRAMED = "snappy-framed";
 
102
 
 
103
    /**
 
104
     * Constant used to identify the "raw" Snappy compression method.
 
105
     * @since 1.7
 
106
     */
 
107
    public static final String SNAPPY_RAW = "snappy-raw";
 
108
 
 
109
    /**
 
110
     * Constant used to identify the traditional Unix compress method.
 
111
     * @since 1.7
 
112
     */
 
113
    public static final String Z = "z";
 
114
 
94
115
    private boolean decompressConcatenated = false;
95
116
 
96
117
    /**
154
175
                return new Pack200CompressorInputStream(in);
155
176
            }
156
177
 
 
178
            if (FramedSnappyCompressorInputStream.matches(signature, signatureLength)) {
 
179
                return new FramedSnappyCompressorInputStream(in);
 
180
            }
 
181
 
157
182
        } catch (IOException e) {
158
183
            throw new CompressorException("Failed to detect Compressor from InputStream.", e);
159
184
        }
164
189
    /**
165
190
     * Create a compressor input stream from a compressor name and an input stream.
166
191
     * 
167
 
     * @param name of the compressor, i.e. "gz", "bzip2", "xz", "lzma", or "pack200"
 
192
     * @param name of the compressor, i.e. "gz", "bzip2", "xz",
 
193
     *        "lzma", "snappy-raw", "snappy-framed", "pack200", "z"
168
194
     * @param in the input stream
169
195
     * @return compressor input stream
170
196
     * @throws CompressorException if the compressor name is not known
180
206
        try {
181
207
 
182
208
            if (GZIP.equalsIgnoreCase(name)) {
183
 
                return new GzipCompressorInputStream(in);
 
209
                return new GzipCompressorInputStream(in, decompressConcatenated);
184
210
            }
185
211
 
186
212
            if (BZIP2.equalsIgnoreCase(name)) {
187
 
                return new BZip2CompressorInputStream(in);
 
213
                return new BZip2CompressorInputStream(in, decompressConcatenated);
188
214
            }
189
215
 
190
216
            if (XZ.equalsIgnoreCase(name)) {
191
 
                return new XZCompressorInputStream(in);
 
217
                return new XZCompressorInputStream(in, decompressConcatenated);
192
218
            }
193
219
 
194
220
            if (LZMA.equalsIgnoreCase(name)) {
199
225
                return new Pack200CompressorInputStream(in);
200
226
            }
201
227
 
 
228
            if (SNAPPY_RAW.equalsIgnoreCase(name)) {
 
229
                return new SnappyCompressorInputStream(in);
 
230
            }
 
231
 
 
232
            if (SNAPPY_FRAMED.equalsIgnoreCase(name)) {
 
233
                return new FramedSnappyCompressorInputStream(in);
 
234
            }
 
235
 
 
236
            if (Z.equalsIgnoreCase(name)) {
 
237
                return new ZCompressorInputStream(in);
 
238
            }
 
239
 
202
240
        } catch (IOException e) {
203
241
            throw new CompressorException(
204
242
                    "Could not create CompressorInputStream.", e);