| 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 | * https://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 <T> The underlying output stream. |
| 58 | * @param name the compressor name, i.e. {@value org.apache.commons.compress.compressors.CompressorStreamFactory#GZIP}, |
| 59 | * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#BZIP2}, |
| 60 | * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#XZ}, |
| 61 | * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#PACK200} or |
| 62 | * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#DEFLATE} |
| 63 | * @param out the output stream |
| 64 | * @return the compressor output stream |
| 65 | * @throws CompressorException if the archiver name is not known |
| 66 | * @throws IllegalArgumentException if the archiver name or stream is null |
| 67 | */ |
| 68 | <T extends OutputStream> CompressorOutputStream<T> createCompressorOutputStream(String name, T out) throws CompressorException; |
| 69 | |
| 70 | /** |
| 71 | * Gets all the input stream compressor names for this provider |
| 72 | * |
| 73 | * @return all the input compressor names for this provider |
| 74 | */ |
| 75 | Set<String> getInputStreamCompressorNames(); |
| 76 | |
| 77 | /** |
| 78 | * Gets all the output stream compressor names for this provider |
| 79 | * |
| 80 | * @return all the output compressor names for this provider |
| 81 | */ |
| 82 | Set<String> getOutputStreamCompressorNames(); |
| 83 | |
| 84 | } |