de.unkrig.commons.file
Class CompressUtil

java.lang.Object
  extended by de.unkrig.commons.file.CompressUtil

public final class CompressUtil
extends java.lang.Object

Utility class which implements functionality that is related to org.apache.commons.compress.


Nested Class Summary
static interface CompressUtil.ArchiveHandler<T>
           
static interface CompressUtil.CompressorHandler<T>
           
static interface CompressUtil.NormalContentsHandler<T>
           
 
Method Summary
static
<T> T
processFile(java.io.File file, Predicate<ArchiveFormat> lookIntoArchive, CompressUtil.ArchiveHandler<? extends T> archiveHandler, Predicate<CompressionFormat> lookIntoCompressed, CompressUtil.CompressorHandler<? extends T> compressorHandler, CompressUtil.NormalContentsHandler<? extends T> normalContentsHandler)
          Invokes exactly one of archiveHandler, compressorHandler or normalContentsHandler.
static
<T> T
processFile(java.lang.String path, java.io.File file, Predicate<java.lang.String> lookIntoFormat, CompressUtil.ArchiveHandler<? extends T> archiveHandler, CompressUtil.CompressorHandler<? extends T> compressorHandler, CompressUtil.NormalContentsHandler<? extends T> normalContentsHandler)
          Invokes exactly one of archiveHandler, compressorHandler or normalContentsHandler.
static
<T> T
processStream(java.io.InputStream inputStream, Predicate<ArchiveFormat> lookIntoArchive, CompressUtil.ArchiveHandler<? extends T> archiveHandler, Predicate<CompressionFormat> lookIntoCompressed, CompressUtil.CompressorHandler<? extends T> compressorHandler, CompressUtil.NormalContentsHandler<? extends T> normalContentsHandler)
          Invokes exactly one of archiveHandler, compressorHandler or normalContentsHandler.
static
<T> T
processStream(java.lang.String path, java.io.InputStream inputStream, Predicate<java.lang.String> lookIntoFormat, CompressUtil.ArchiveHandler<? extends T> archiveHandler, CompressUtil.CompressorHandler<? extends T> compressorHandler, CompressUtil.NormalContentsHandler<? extends T> normalContentsHandler)
          Invokes exactly one of archiveHandler, compressorHandler or normalContentsHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

processStream

@Nullable
public static <T> T processStream(java.lang.String path,
                                           java.io.InputStream inputStream,
                                           Predicate<java.lang.String> lookIntoFormat,
                                           CompressUtil.ArchiveHandler<? extends T> archiveHandler,
                                           CompressUtil.CompressorHandler<? extends T> compressorHandler,
                                           CompressUtil.NormalContentsHandler<? extends T> normalContentsHandler)
                       throws java.io.IOException
Invokes exactly one of archiveHandler, compressorHandler or normalContentsHandler.

An archive file is introspected iff lookIntoFormat evaluates to true for "<i>archive-format-name</i>:<i>path</i>".

A compressed file is introspected iff lookIntoFormat evaluates to true for "<i>compression-format-name</i>:<i>path</i>".

Throws:
java.io.IOException
See Also:
ArchiveFormatFactory.allFormats(), CompressionFormatFactory.allFormats()

processStream

@Nullable
public static <T> T processStream(java.io.InputStream inputStream,
                                           Predicate<ArchiveFormat> lookIntoArchive,
                                           CompressUtil.ArchiveHandler<? extends T> archiveHandler,
                                           Predicate<CompressionFormat> lookIntoCompressed,
                                           CompressUtil.CompressorHandler<? extends T> compressorHandler,
                                           CompressUtil.NormalContentsHandler<? extends T> normalContentsHandler)
                       throws java.io.IOException
Invokes exactly one of archiveHandler, compressorHandler or normalContentsHandler.

Parameters:
lookIntoArchive - An archive stream is introspected iff lookIntoArchive evaluates to true for the archive format
lookIntoCompressed - A compressed stream is introspected iff lookIntoCompressed evaluates to true for the compression format
Throws:
java.io.IOException
See Also:
CompressionFormatFactory.allFormats()

processFile

@Nullable
public static <T> T processFile(java.lang.String path,
                                         java.io.File file,
                                         Predicate<java.lang.String> lookIntoFormat,
                                         CompressUtil.ArchiveHandler<? extends T> archiveHandler,
                                         CompressUtil.CompressorHandler<? extends T> compressorHandler,
                                         CompressUtil.NormalContentsHandler<? extends T> normalContentsHandler)
                     throws java.io.IOException
Invokes exactly one of archiveHandler, compressorHandler or normalContentsHandler.

An archive file is introspected iff lookIntoFormat evaluates to true for "archive-format-name:path".

A compressed file is introspected iff lookIntoFormat evaluates to true for "compression-format-name:path".

Throws:
java.io.IOException
See Also:
ArchiveFormatFactory.allFormats(), CompressionFormatFactory.allFormats()

processFile

@Nullable
public static <T> T processFile(java.io.File file,
                                         Predicate<ArchiveFormat> lookIntoArchive,
                                         CompressUtil.ArchiveHandler<? extends T> archiveHandler,
                                         Predicate<CompressionFormat> lookIntoCompressed,
                                         CompressUtil.CompressorHandler<? extends T> compressorHandler,
                                         CompressUtil.NormalContentsHandler<? extends T> normalContentsHandler)
                     throws java.io.IOException
Invokes exactly one of archiveHandler, compressorHandler or normalContentsHandler.

Parameters:
lookIntoArchive - An archive file is introspected iff lookIntoArchive evaluates to true for the archive format
lookIntoCompressed - A compressed file is introspected iff lookIntoCompressed evaluates to true for the compression format
Throws:
java.io.IOException
See Also:
CompressionFormatFactory.allFormats()