public final class ContentsProcessings
extends java.lang.Object
ContentsProcessor-related utility methods.| Modifier and Type | Class and Description |
|---|---|
static interface |
ContentsProcessings.ArchiveCombiner<T>
Combines the results of
ContentsProcessor.process(String, InputStream, long, long, ProducerWhichThrows)
for all archive entries into one object. |
| Modifier and Type | Method and Description |
|---|---|
static <T> CompressUtil.ArchiveHandler<T> |
archiveHandler(java.lang.String path,
ContentsProcessor<T> contentsProcessor,
ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner,
ProducerWhichThrows<? extends java.io.InputStream,? extends java.io.IOException> opener,
ExceptionHandler<java.io.IOException> exceptionHandler)
Creates and returns an
CompressUtil.ArchiveHandler which processes ArchiveInputStreams by feeding their
entries into the contentsProcessor. |
static <T> ContentsProcessor<T> |
compressedAndArchiveContentsProcessor(Predicate<? super java.lang.String> lookIntoFormat,
ContentsProcessor<T> archiveContentsProcessor,
ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner,
ContentsProcessor<T> compressedContentsProcessor,
ContentsProcessor<T> normalContentsProcessor,
ExceptionHandler<java.io.IOException> exceptionHandler)
Returns a
ContentsProcessor which processes contents by feeding it to the normalContentsProcessor, but automagically detects various archive and compression formats and processes the
entries of the archive and the uncompressed contents instead of the "raw" contents. |
static <T> CompressUtil.CompressorHandler<T> |
compressorHandler(java.lang.String path,
ContentsProcessor<T> contentsProcessor,
ProducerWhichThrows<? extends java.io.InputStream,? extends java.io.IOException> opener)
Creates and returns a
CompressUtil.CompressorHandler which processes an ArchiveInputStream by feeding its
entries to the given contentsProcessor. |
static <T> ContentsProcessings.ArchiveCombiner<T> |
nopArchiveCombiner() |
static <T> ContentsProcessor<T> |
nopContentsProcessor() |
static <T> CompressUtil.NormalContentsHandler<T> |
normalContentsHandler(java.lang.String path,
ContentsProcessor<T> contentsProcessor,
long size,
long crc32,
ProducerWhichThrows<? extends java.io.InputStream,? extends java.io.IOException> opener)
Creates and returns a
TransformerWhichThrows which processes an InputStream by feeding it into
the given contentsProcessor. |
static <T> T |
processArchive(java.lang.String archivePath,
org.apache.commons.compress.archivers.ArchiveInputStream archiveInputStream,
ContentsProcessor<T> contentsProcessor,
ContentsProcessings.ArchiveCombiner<T> entryCombiner,
ProducerWhichThrows<? extends org.apache.commons.compress.archivers.ArchiveInputStream,? extends java.io.IOException> archiveOpener,
ExceptionHandler<java.io.IOException> exceptionHandler)
Process the given
archiveInputStream by feeding the contents of each archive entry through the given
contentsProcessor. |
static <T> ContentsProcessor<T> |
recursiveCompressedAndArchiveContentsProcessor(Predicate<? super java.lang.String> lookIntoFormat,
ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner,
ContentsProcessor<T> normalContentsProcessor,
ExceptionHandler<java.io.IOException> exceptionHandler)
Returns a
ContentsProcessor which processes a stream by feeding it into the normalContentsProcessor, but automagically detects various archive formats and compression formats (also
nested) and processes the entries of the archive and the uncompressed contents instead of the
"raw" contents. |
public static <T> ContentsProcessor<T> nopContentsProcessor()
ContentsProcessor that does not read any of the contents, and evaluates to null.public static <T> ContentsProcessings.ArchiveCombiner<T> nopArchiveCombiner()
ContentsProcessings.ArchiveCombiner which always returns null@Nullable public static <T> T processArchive(java.lang.String archivePath, org.apache.commons.compress.archivers.ArchiveInputStream archiveInputStream, ContentsProcessor<T> contentsProcessor, ContentsProcessings.ArchiveCombiner<T> entryCombiner, ProducerWhichThrows<? extends org.apache.commons.compress.archivers.ArchiveInputStream,? extends java.io.IOException> archiveOpener, ExceptionHandler<java.io.IOException> exceptionHandler) throws java.io.IOException
archiveInputStream by feeding the contents of each archive entry through the given
contentsProcessor.archiveOpener - Re-produces the archive input streamexceptionHandler - Invoked if the contentsProcessor throws an exception; if it completes normally,
then processing continues with the next archive entryjava.io.IOExceptionpublic static <T> ContentsProcessor<T> compressedAndArchiveContentsProcessor(Predicate<? super java.lang.String> lookIntoFormat, ContentsProcessor<T> archiveContentsProcessor, ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner, ContentsProcessor<T> compressedContentsProcessor, ContentsProcessor<T> normalContentsProcessor, ExceptionHandler<java.io.IOException> exceptionHandler)
ContentsProcessor which processes contents by feeding it to the normalContentsProcessor, but automagically detects various archive and compression formats and processes the
entries of the archive and the uncompressed contents instead of the "raw" contents.
Archive files and compressed files are introspected iff lookIntoFormat evaluates true for
"format:path".
public static <T> ContentsProcessor<T> recursiveCompressedAndArchiveContentsProcessor(Predicate<? super java.lang.String> lookIntoFormat, ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner, ContentsProcessor<T> normalContentsProcessor, ExceptionHandler<java.io.IOException> exceptionHandler)
ContentsProcessor which processes a stream by feeding it into the normalContentsProcessor, but automagically detects various archive formats and compression formats (also
nested) and processes the entries of the archive and the uncompressed contents instead of the
"raw" contents.
Archive streams/entries and compressed streams/entries are introspected iff lookIntoFormat evaluates
true for "format:path".
public static <T> CompressUtil.ArchiveHandler<T> archiveHandler(java.lang.String path, ContentsProcessor<T> contentsProcessor, ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner, ProducerWhichThrows<? extends java.io.InputStream,? extends java.io.IOException> opener, ExceptionHandler<java.io.IOException> exceptionHandler)
CompressUtil.ArchiveHandler which processes ArchiveInputStreams by feeding their
entries into the contentsProcessor.opener - Will be invoked later when the returned archive handler processes a concrete archivepublic static <T> CompressUtil.CompressorHandler<T> compressorHandler(java.lang.String path, ContentsProcessor<T> contentsProcessor, ProducerWhichThrows<? extends java.io.InputStream,? extends java.io.IOException> opener)
CompressUtil.CompressorHandler which processes an ArchiveInputStream by feeding its
entries to the given contentsProcessor.opener - Re-produces the input streampublic static <T> CompressUtil.NormalContentsHandler<T> normalContentsHandler(java.lang.String path, ContentsProcessor<T> contentsProcessor, long size, long crc32, ProducerWhichThrows<? extends java.io.InputStream,? extends java.io.IOException> opener)
TransformerWhichThrows which processes an InputStream by feeding it into
the given contentsProcessor.size - -1 if unknowncrc32 - See ContentsProcessor.process(String, InputStream, long, long, ProducerWhichThrows)opener - Re-produces the