Example usage for org.apache.commons.compress.archivers StreamingNotSupportedException StreamingNotSupportedException

List of usage examples for org.apache.commons.compress.archivers StreamingNotSupportedException StreamingNotSupportedException

Introduction

In this page you can find the example usage for org.apache.commons.compress.archivers StreamingNotSupportedException StreamingNotSupportedException.

Prototype

public StreamingNotSupportedException(final String format) 

Source Link

Document

Creates a new StreamingNotSupportedException.

Usage

From source file:org.apache.tika.parser.pkg.TikaArchiveStreamFactory.java

@Override
public ArchiveInputStream createArchiveInputStream(final String archiverName, final InputStream in,
        final String actualEncoding) throws ArchiveException {

    if (archiverName == null) {
        throw new IllegalArgumentException("Archivername must not be null.");
    }/*w  w w .  j av  a  2  s .  c  o m*/

    if (in == null) {
        throw new IllegalArgumentException("InputStream must not be null.");
    }

    if (AR.equalsIgnoreCase(archiverName)) {
        return new ArArchiveInputStream(in);
    }
    if (ARJ.equalsIgnoreCase(archiverName)) {
        if (actualEncoding != null) {
            return new ArjArchiveInputStream(in, actualEncoding);
        }
        return new ArjArchiveInputStream(in);
    }
    if (ZIP.equalsIgnoreCase(archiverName)) {
        if (actualEncoding != null) {
            return new ZipArchiveInputStream(in, actualEncoding);
        }
        return new ZipArchiveInputStream(in);
    }
    if (TAR.equalsIgnoreCase(archiverName)) {
        if (actualEncoding != null) {
            return new TarArchiveInputStream(in, actualEncoding);
        }
        return new TarArchiveInputStream(in);
    }
    if (JAR.equalsIgnoreCase(archiverName)) {
        if (actualEncoding != null) {
            return new JarArchiveInputStream(in, actualEncoding);
        }
        return new JarArchiveInputStream(in);
    }
    if (CPIO.equalsIgnoreCase(archiverName)) {
        if (actualEncoding != null) {
            return new CpioArchiveInputStream(in, actualEncoding);
        }
        return new CpioArchiveInputStream(in);
    }
    if (DUMP.equalsIgnoreCase(archiverName)) {
        if (actualEncoding != null) {
            return new DumpArchiveInputStream(in, actualEncoding);
        }
        return new DumpArchiveInputStream(in);
    }
    if (SEVEN_Z.equalsIgnoreCase(archiverName)) {
        throw new StreamingNotSupportedException(SEVEN_Z);
    }

    final ArchiveStreamProvider archiveStreamProvider = getArchiveInputStreamProviders()
            .get(toKey(archiverName));
    if (archiveStreamProvider != null) {
        return archiveStreamProvider.createArchiveInputStream(archiverName, in, actualEncoding);
    }

    throw new ArchiveException("Archiver: " + archiverName + " not found.");
}

From source file:org.apache.tika.parser.pkg.TikaArchiveStreamFactory.java

@Override
public ArchiveOutputStream createArchiveOutputStream(final String archiverName, final OutputStream out,
        final String actualEncoding) throws ArchiveException {
    if (archiverName == null) {
        throw new IllegalArgumentException("Archivername must not be null.");
    }//w  ww  . j  a  va  2 s .c om
    if (out == null) {
        throw new IllegalArgumentException("OutputStream must not be null.");
    }

    if (AR.equalsIgnoreCase(archiverName)) {
        return new ArArchiveOutputStream(out);
    }
    if (ZIP.equalsIgnoreCase(archiverName)) {
        final ZipArchiveOutputStream zip = new ZipArchiveOutputStream(out);
        if (actualEncoding != null) {
            zip.setEncoding(actualEncoding);
        }
        return zip;
    }
    if (TAR.equalsIgnoreCase(archiverName)) {
        if (actualEncoding != null) {
            return new TarArchiveOutputStream(out, actualEncoding);
        }
        return new TarArchiveOutputStream(out);
    }
    if (JAR.equalsIgnoreCase(archiverName)) {
        if (actualEncoding != null) {
            return new JarArchiveOutputStream(out, actualEncoding);
        }
        return new JarArchiveOutputStream(out);
    }
    if (CPIO.equalsIgnoreCase(archiverName)) {
        if (actualEncoding != null) {
            return new CpioArchiveOutputStream(out, actualEncoding);
        }
        return new CpioArchiveOutputStream(out);
    }
    if (SEVEN_Z.equalsIgnoreCase(archiverName)) {
        throw new StreamingNotSupportedException(SEVEN_Z);
    }

    final ArchiveStreamProvider archiveStreamProvider = getArchiveOutputStreamProviders()
            .get(toKey(archiverName));
    if (archiveStreamProvider != null) {
        return archiveStreamProvider.createArchiveOutputStream(archiverName, out, actualEncoding);
    }

    throw new ArchiveException("Archiver: " + archiverName + " not found.");
}