    001/*
    002 * Licensed to the Apache Software Foundation (ASF) under one
    003 * or more contributor license agreements.  See the NOTICE file
    004 * distributed with this work for additional information
    005 * regarding copyright ownership.  The ASF licenses this file
    006 * to you under the Apache License, Version 2.0 (the
    007 * "License"); you may not use this file except in compliance
    008 * with the License.  You may obtain a copy of the License at
    009 *
    010 * http://www.apache.org/licenses/LICENSE-2.0
    011 *
    012 * Unless required by applicable law or agreed to in writing,
    013 * software distributed under the License is distributed on an
    014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
    015 * KIND, either express or implied.  See the License for the
    016 * specific language governing permissions and limitations
    017 * under the License.
    018 */
    019
    020package org.apache.commons.compress.archivers;
    021
    022import java.io.InputStream;
    023import java.io.OutputStream;
    024import java.util.Set;
    025
    026/**
    027 * Creates Archive {@link ArchiveInputStream}s and {@link ArchiveOutputStream}s.
    028 *
    029 * @since 1.13
    030 */
    031public interface ArchiveStreamProvider {
    032
    033    /**
    034     * Creates an archive input stream from an archiver name and an input
    035     * stream.
    036     *
    037     * @param name
    038     *            the archive name, i.e.
    039     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#AR},
    040     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#ARJ},
    041     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#ZIP},
    042     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#TAR},
    043     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#JAR},
    044     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#CPIO},
    045     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#DUMP}
    046     *            or
    047     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#SEVEN_Z}
    048     * @param in
    049     *            the input stream
    050     * @param encoding
    051     *            encoding name or null for the default
    052     * @return the archive input stream
    053     * @throws ArchiveException
    054     *             if the archiver name is not known
    055     * @throws StreamingNotSupportedException
    056     *             if the format cannot be read from a stream
    057     * @throws IllegalArgumentException
    058     *             if the archiver name or stream is null
    059     */
    060    ArchiveInputStream createArchiveInputStream(final String name, final InputStream in, final String encoding)
    061            throws ArchiveException;
    062
    063    /**
    064     * Creates an archive output stream from an archiver name and an output
    065     * stream.
    066     *
    067     * @param name
    068     *            the archive name, i.e.
    069     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#AR},
    070     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#ZIP},
    071     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#TAR},
    072     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#JAR}
    073     *            or
    074     *            {@value org.apache.commons.compress.archivers.ArchiveStreamFactory#CPIO}
    075     * @param out
    076     *            the output stream
    077     * @param encoding
    078     *            encoding name or null for the default
    079     * @return the archive output stream
    080     * @throws ArchiveException
    081     *             if the archiver name is not known
    082     * @throws StreamingNotSupportedException
    083     *             if the format cannot be written to a stream
    084     * @throws IllegalArgumentException
    085     *             if the archiver name or stream is null
    086     */
    087    ArchiveOutputStream createArchiveOutputStream(final String name, final OutputStream out, final String encoding)
    088            throws ArchiveException;
    089
    090    /**
    091     * Gets all the input stream archive names for this provider
    092     *
    093     * @return all the input archive names for this provider
    094     */
    095    Set<String> getInputStreamArchiveNames();
    096
    097    /**
    098     * Gets all the output stream archive names for this provider
    099     *
    100     * @return all the output archive names for this provider
    101     */
    102    Set<String> getOutputStreamArchiveNames();
    103
    104}