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 28 * {@link CompressorOutputStream}s. 29 * 30 * @since 1.13 31 */ 32 public interface CompressorStreamProvider { 33 34 /** 35 * Creates a compressor input stream from a compressor name and an input 36 * stream. 37 * 38 * @param name 39 * of the compressor, i.e. 40 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#GZIP}, 41 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#BZIP2}, 42 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#XZ}, 43 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#LZMA}, 44 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#PACK200}, 45 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#SNAPPY_RAW}, 46 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#SNAPPY_FRAMED}, 47 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#Z} 48 * or 49 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#DEFLATE} 50 * @param in 51 * the input stream 52 * @param decompressUntilEOF 53 * if true, decompress until the end of the input; if false, stop 54 * after the first stream and leave the input position to point 55 * to the next byte after the stream. This setting applies to the 56 * gzip, bzip2 and xz formats only. 57 * @return compressor input stream 58 * @throws CompressorException 59 * if the compressor name is not known 60 * @throws IllegalArgumentException 61 * if the name or input stream is null 62 */ createCompressorInputStream(final String name, final InputStream in, final boolean decompressUntilEOF)63 CompressorInputStream createCompressorInputStream(final String name, final InputStream in, 64 final boolean decompressUntilEOF) throws CompressorException; 65 66 /** 67 * Creates a compressor output stream from an compressor name and an output 68 * stream. 69 * 70 * @param name 71 * the compressor name, i.e. 72 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#GZIP}, 73 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#BZIP2}, 74 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#XZ}, 75 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#PACK200} 76 * or 77 * {@value org.apache.commons.compress.compressors.CompressorStreamFactory#DEFLATE} 78 * @param out 79 * the output stream 80 * @return the compressor output stream 81 * @throws CompressorException 82 * if the archiver name is not known 83 * @throws IllegalArgumentException 84 * if the archiver name or stream is null 85 */ createCompressorOutputStream(final String name, final OutputStream out)86 CompressorOutputStream createCompressorOutputStream(final String name, final OutputStream out) 87 throws CompressorException; 88 89 /** 90 * Gets all the input stream compressor names for this provider 91 * 92 * @return all the input compressor names for this provider 93 */ getInputStreamCompressorNames()94 Set<String> getInputStreamCompressorNames(); 95 96 /** 97 * Gets all the output stream compressor names for this provider 98 * 99 * @return all the output compressor names for this provider 100 */ getOutputStreamCompressorNames()101 Set<String> getOutputStreamCompressorNames(); 102 103 } 104