| 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.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 stream. |
| 35 | * |
| 36 | * @param <I> The {@link ArchiveInputStream} type. |
| 37 | * @param archiverName the archiver name, i.e. {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#AR}, |
| 38 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#ARJ}, |
| 39 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#ZIP}, |
| 40 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#TAR}, |
| 41 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#JAR}, |
| 42 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#CPIO}, |
| 43 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#DUMP} or |
| 44 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#SEVEN_Z} |
| 45 | * @param inputStream the input stream |
| 46 | * @param encoding encoding name or null for the default |
| 47 | * @return the archive input stream |
| 48 | * @throws ArchiveException if the archiver name is not known |
| 49 | * @throws StreamingNotSupportedException if the format cannot be read from a stream |
| 50 | * @throws IllegalArgumentException if the archiver name or stream is null |
| 51 | */ |
| 52 | <I extends ArchiveInputStream<? extends ArchiveEntry>> I createArchiveInputStream(String archiverName, InputStream inputStream, String encoding) |
| 53 | throws ArchiveException; |
| 54 | |
| 55 | /** |
| 56 | * Creates an archive output stream from an archiver name and an output stream. |
| 57 | * |
| 58 | * @param <O> The {@link ArchiveInputStream} type. |
| 59 | * @param archiverName the archiver name, i.e. {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#AR}, |
| 60 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#ZIP}, |
| 61 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#TAR}, |
| 62 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#JAR} or |
| 63 | * {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#CPIO} |
| 64 | * @param outputStream the output stream |
| 65 | * @param encoding encoding name or null for the default |
| 66 | * @return the archive output stream |
| 67 | * @throws ArchiveException if the archiver name is not known |
| 68 | * @throws StreamingNotSupportedException if the format cannot be written to a stream |
| 69 | * @throws IllegalArgumentException if the archiver name or stream is null |
| 70 | */ |
| 71 | <O extends ArchiveOutputStream<? extends ArchiveEntry>> O createArchiveOutputStream(String archiverName, OutputStream outputStream, String encoding) |
| 72 | throws ArchiveException; |
| 73 | |
| 74 | /** |
| 75 | * Gets all the input stream archive names for this provider |
| 76 | * |
| 77 | * @return all the input archive names for this provider |
| 78 | */ |
| 79 | Set<String> getInputStreamArchiveNames(); |
| 80 | |
| 81 | /** |
| 82 | * Gets all the output stream archive names for this provider |
| 83 | * |
| 84 | * @return all the output archive names for this provider |
| 85 | */ |
| 86 | Set<String> getOutputStreamArchiveNames(); |
| 87 | |
| 88 | } |