public final class ContentsProcessings extends 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(String path,
ContentsProcessor<T> contentsProcessor,
ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner,
ProducerWhichThrows<? extends InputStream,? extends IOException> opener,
ExceptionHandler<IOException> exceptionHandler)
Creates and returns an
CompressUtil.ArchiveHandler which processes ArchiveInputStream s by feeding their
entries into the contentsProcessor. |
static <T> ContentsProcessor<T> |
compressedAndArchiveContentsProcessor(Predicate<? super String> lookIntoFormat,
Predicate<? super String> pathPredicate,
ContentsProcessor<T> archiveContentsProcessor,
ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner,
ContentsProcessor<T> compressedContentsProcessor,
ContentsProcessor<T> normalContentsProcessor,
ExceptionHandler<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(String path,
ContentsProcessor<T> contentsProcessor,
ProducerWhichThrows<? extends InputStream,? extends 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(String path,
ContentsProcessor<T> contentsProcessor,
long size,
long crc32,
ProducerWhichThrows<? extends InputStream,? extends IOException> opener)
Creates and returns a
TransformerWhichThrows which processes an InputStream by feeding it into
the given contentsProcessor. |
static <T> T |
processArchive(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 IOException> archiveOpener,
ExceptionHandler<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 String> lookIntoFormat,
Predicate<? super String> pathPredicate,
ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner,
ContentsProcessor<T> normalContentsProcessor,
ExceptionHandler<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(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 IOException> archiveOpener, ExceptionHandler<IOException> exceptionHandler) throws IOException
"Directory archive entries" are silently ignored, because they have no contents and thus it makes no sense to process them with the 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 entryIOException
public static <T> ContentsProcessor<T> compressedAndArchiveContentsProcessor(Predicate<? super String> lookIntoFormat, Predicate<? super String> pathPredicate, ContentsProcessor<T> archiveContentsProcessor, ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner, ContentsProcessor<T> compressedContentsProcessor, ContentsProcessor<T> normalContentsProcessor, ExceptionHandler<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 String> lookIntoFormat, Predicate<? super String> pathPredicate, ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner, ContentsProcessor<T> normalContentsProcessor, ExceptionHandler<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(String path, ContentsProcessor<T> contentsProcessor, ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner, ProducerWhichThrows<? extends InputStream,? extends IOException> opener, ExceptionHandler<IOException> exceptionHandler)
CompressUtil.ArchiveHandler
which processes ArchiveInputStream
s 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(String path, ContentsProcessor<T> contentsProcessor, ProducerWhichThrows<? extends InputStream,? extends 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(String path, ContentsProcessor<T> contentsProcessor, long size, long crc32, ProducerWhichThrows<? extends InputStream,? extends 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 theCopyright © 2018 Arno Unkrig. All rights reserved.