View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  
20  package org.apache.commons.compress.compressors;
21  
22  import java.io.InputStream;
23  import java.io.OutputStream;
24  import java.util.Set;
25  
26  /**
27   * Creates Compressor {@link CompressorInputStream}s and {@link CompressorOutputStream}s.
28   *
29   * @since 1.13
30   */
31  public interface CompressorStreamProvider {
32  
33      /**
34       * Creates a compressor input stream from a compressor name and an input stream.
35       *
36       * @param name               of the compressor, i.e. {@value org.apache.commons.compress.compressors.CompressorStreamFactory#GZIP},
37       *                           {@value org.apache.commons.compress.compressors.CompressorStreamFactory#BZIP2},
38       *                           {@value org.apache.commons.compress.compressors.CompressorStreamFactory#XZ},
39       *                           {@value org.apache.commons.compress.compressors.CompressorStreamFactory#LZMA},
40       *                           {@value org.apache.commons.compress.compressors.CompressorStreamFactory#PACK200},
41       *                           {@value org.apache.commons.compress.compressors.CompressorStreamFactory#SNAPPY_RAW},
42       *                           {@value org.apache.commons.compress.compressors.CompressorStreamFactory#SNAPPY_FRAMED},
43       *                           {@value org.apache.commons.compress.compressors.CompressorStreamFactory#Z} or
44       *                           {@value org.apache.commons.compress.compressors.CompressorStreamFactory#DEFLATE}
45       * @param in                 the input stream
46       * @param decompressUntilEOF if true, decompress until the end of the input; if false, stop after the first stream and leave the input position to point to
47       *                           the next byte after the stream. This setting applies to the gzip, bzip2 and XZ formats only.
48       * @return compressor input stream
49       * @throws CompressorException      if the compressor name is not known
50       * @throws IllegalArgumentException if the name or input stream is null
51       */
52      CompressorInputStream createCompressorInputStream(String name, InputStream in, boolean decompressUntilEOF) throws CompressorException;
53  
54      /**
55       * Creates a compressor output stream from a compressor name and an output stream.
56       *
57       * @param name the compressor name, i.e. {@value org.apache.commons.compress.compressors.CompressorStreamFactory#GZIP},
58       *             {@value org.apache.commons.compress.compressors.CompressorStreamFactory#BZIP2},
59       *             {@value org.apache.commons.compress.compressors.CompressorStreamFactory#XZ},
60       *             {@value org.apache.commons.compress.compressors.CompressorStreamFactory#PACK200} or
61       *             {@value org.apache.commons.compress.compressors.CompressorStreamFactory#DEFLATE}
62       * @param out  the output stream
63       * @return the compressor output stream
64       * @throws CompressorException      if the archiver name is not known
65       * @throws IllegalArgumentException if the archiver name or stream is null
66       */
67      CompressorOutputStream createCompressorOutputStream(String name, OutputStream out) throws CompressorException;
68  
69      /**
70       * Gets all the input stream compressor names for this provider
71       *
72       * @return all the input compressor names for this provider
73       */
74      Set<String> getInputStreamCompressorNames();
75  
76      /**
77       * Gets all the output stream compressor names for this provider
78       *
79       * @return all the output compressor names for this provider
80       */
81      Set<String> getOutputStreamCompressorNames();
82  
83  }