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.archivers; 21 22 import java.io.InputStream; 23 import java.io.OutputStream; 24 import java.util.Set; 25 26 /** 27 * Creates Archive {@link ArchiveInputStream}s and {@link ArchiveOutputStream}s. 28 * 29 * @since 1.13 30 */ 31 public interface ArchiveStreamProvider { 32 33 /** 34 * Creates an archive input stream from an archiver name and an input 35 * stream. 36 * 37 * @param name 38 * the archive name, i.e. 39 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#AR}, 40 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#ARJ}, 41 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#ZIP}, 42 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#TAR}, 43 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#JAR}, 44 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#CPIO}, 45 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#DUMP} 46 * or 47 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#SEVEN_Z} 48 * @param in 49 * the input stream 50 * @param encoding 51 * encoding name or null for the default 52 * @return the archive input stream 53 * @throws ArchiveException 54 * if the archiver name is not known 55 * @throws StreamingNotSupportedException 56 * if the format cannot be read from a stream 57 * @throws IllegalArgumentException 58 * if the archiver name or stream is null 59 */ createArchiveInputStream(final String name, final InputStream in, final String encoding)60 ArchiveInputStream createArchiveInputStream(final String name, final InputStream in, final String encoding) 61 throws ArchiveException; 62 63 /** 64 * Creates an archive output stream from an archiver name and an output 65 * stream. 66 * 67 * @param name 68 * the archive name, i.e. 69 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#AR}, 70 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#ZIP}, 71 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#TAR}, 72 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#JAR} 73 * or 74 * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#CPIO} 75 * @param out 76 * the output stream 77 * @param encoding 78 * encoding name or null for the default 79 * @return the archive output stream 80 * @throws ArchiveException 81 * if the archiver name is not known 82 * @throws StreamingNotSupportedException 83 * if the format cannot be written to a stream 84 * @throws IllegalArgumentException 85 * if the archiver name or stream is null 86 */ createArchiveOutputStream(final String name, final OutputStream out, final String encoding)87 ArchiveOutputStream createArchiveOutputStream(final String name, final OutputStream out, final String encoding) 88 throws ArchiveException; 89 90 /** 91 * Gets all the input stream archive names for this provider 92 * 93 * @return all the input archive names for this provider 94 */ getInputStreamArchiveNames()95 Set<String> getInputStreamArchiveNames(); 96 97 /** 98 * Gets all the output stream archive names for this provider 99 * 100 * @return all the output archive names for this provider 101 */ getOutputStreamArchiveNames()102 Set<String> getOutputStreamArchiveNames(); 103 104 } 105