public final class ContentsTransformations extends Object
ContentsTransformer
.Modifier and Type | Field and Description |
---|---|
static ContentsTransformer |
COPY
A
ContentsTransformer which IoUtil.copy(InputStream, OutputStream) s all data unmodified and
returns the number of copied bytes. |
Modifier and Type | Method and Description |
---|---|
static CompressUtil.ArchiveHandler<Void> |
archiveHandler(String path,
OutputStream os,
Predicate<? super String> archiveEntryRemoval,
de.unkrig.commons.text.pattern.Glob archiveEntryRenaming,
ContentsTransformer contentsTransformer,
FileTransformations.ArchiveCombiner archiveFileCombiner,
ExceptionHandler<IOException> exceptionHandler)
Creates and returns an
CompressUtil.ArchiveHandler which transforms ArchiveInputStream s into ArchiveOutputStream s, honoring the given archiveEntryRemoval, archiveEntryRenaming and
archiveFileCombiner, and using the given contentsTransformer. |
static InputStream |
asInputStream(InputStream delegate,
ContentsTransformer transformer,
String name)
Creates and returns an
InputStream that reads from the delegate and through the
transformer |
static OutputStream |
asOutputStream(ContentsTransformer transformer,
OutputStream delegate,
String name)
Creates and returns an
OutputStream that writes through the transformer and to the
delegate. |
static ContentsTransformer |
chain(ContentsTransformer transformer1,
ContentsTransformer transformer2)
Creates and returns a
ContentsTransformer s that "chains" the two delegates. |
static ContentsTransformer |
compressedAndArchiveContentsTransformer(Predicate<? super String> lookIntoFormat,
Predicate<? super String> archiveEntryRemoval,
de.unkrig.commons.text.pattern.Glob archiveEntryRenaming,
ContentsTransformer archiveEntryContentsTransformer,
FileTransformations.ArchiveCombiner archiveCombiner,
ContentsTransformer compressedContentsTransformer,
ContentsTransformer normalContentsTransformer,
ExceptionHandler<IOException> exceptionHandler)
Returns a
ContentsTransformer which transforms contents by feeding it through the normalContentsTransformer , 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 CompressUtil.CompressorHandler<Void> |
compressorHandler(String path,
OutputStream os,
ContentsTransformer contentsTransformer)
Creates and returns a
CompressUtil.CompressorHandler which transforms an ArchiveInputStream into an OutputStream , using the given contentsTransformer. |
static CompressUtil.NormalContentsHandler<Void> |
normalContentsHandler(String path,
OutputStream os,
ContentsTransformer contentsTransformer)
Creates and returns a handler which transforms an
InputStream into an OutputStream using the
given contentsTransformer. |
static ContentsTransformer |
recursiveCompressedAndArchiveContentsTransformer(Predicate<? super String> lookIntoFormat,
Predicate<? super String> archiveEntryRemoval,
de.unkrig.commons.text.pattern.Glob archiveEntryRenaming,
FileTransformations.ArchiveCombiner archiveCombiner,
ContentsTransformer delegate,
ExceptionHandler<IOException> exceptionHandler)
Returns a
ContentsTransformer which transforms a stream by feeding it through the delegate,
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. |
static void |
transformArchive(String path,
org.apache.commons.compress.archivers.ArchiveInputStream archiveInputStream,
org.apache.commons.compress.archivers.ArchiveOutputStream archiveOutputStream,
Predicate<? super String> archiveEntryRemoval,
de.unkrig.commons.text.pattern.Glob archiveEntryRenaming,
ContentsTransformer contentsTransformer,
FileTransformations.ArchiveCombiner archiveCombiner,
ExceptionHandler<IOException> exceptionHandler)
Transforms the given archiveInputStream into the given archiveOutputStream, honoring the
given archiveEntryRemoval, archiveEntryRenaming and archiveEntryAddition, and
using the given contentsTransformer.
|
public static final ContentsTransformer COPY
ContentsTransformer
which IoUtil.copy(InputStream, OutputStream)
s all data unmodified and
returns the number of copied bytes.public static ContentsTransformer compressedAndArchiveContentsTransformer(Predicate<? super String> lookIntoFormat, Predicate<? super String> archiveEntryRemoval, de.unkrig.commons.text.pattern.Glob archiveEntryRenaming, ContentsTransformer archiveEntryContentsTransformer, FileTransformations.ArchiveCombiner archiveCombiner, ContentsTransformer compressedContentsTransformer, ContentsTransformer normalContentsTransformer, ExceptionHandler<IOException> exceptionHandler)
ContentsTransformer
which transforms contents by feeding it through the normalContentsTransformer
, 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 ContentsTransformer recursiveCompressedAndArchiveContentsTransformer(Predicate<? super String> lookIntoFormat, Predicate<? super String> archiveEntryRemoval, de.unkrig.commons.text.pattern.Glob archiveEntryRenaming, FileTransformations.ArchiveCombiner archiveCombiner, ContentsTransformer delegate, ExceptionHandler<IOException> exceptionHandler)
ContentsTransformer
which transforms a stream by feeding it through the delegate,
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 void transformArchive(String path, org.apache.commons.compress.archivers.ArchiveInputStream archiveInputStream, org.apache.commons.compress.archivers.ArchiveOutputStream archiveOutputStream, Predicate<? super String> archiveEntryRemoval, de.unkrig.commons.text.pattern.Glob archiveEntryRenaming, ContentsTransformer contentsTransformer, FileTransformations.ArchiveCombiner archiveCombiner, ExceptionHandler<IOException> exceptionHandler) throws IOException
IOException
public static CompressUtil.ArchiveHandler<Void> archiveHandler(String path, OutputStream os, Predicate<? super String> archiveEntryRemoval, de.unkrig.commons.text.pattern.Glob archiveEntryRenaming, ContentsTransformer contentsTransformer, FileTransformations.ArchiveCombiner archiveFileCombiner, ExceptionHandler<IOException> exceptionHandler)
CompressUtil.ArchiveHandler
which transforms ArchiveInputStream
s into ArchiveOutputStream
s, honoring the given archiveEntryRemoval, archiveEntryRenaming and
archiveFileCombiner, and using the given contentsTransformer.public static CompressUtil.CompressorHandler<Void> compressorHandler(String path, OutputStream os, ContentsTransformer contentsTransformer)
CompressUtil.CompressorHandler
which transforms an ArchiveInputStream
into an OutputStream
, using the given contentsTransformer.public static CompressUtil.NormalContentsHandler<Void> normalContentsHandler(String path, OutputStream os, ContentsTransformer contentsTransformer)
InputStream
into an OutputStream
using the
given contentsTransformer.public static ContentsTransformer chain(ContentsTransformer transformer1, ContentsTransformer transformer2)
ContentsTransformer
s that "chains" the two delegates.
If neither of the two delegate transformers is COPY
, then the returned
transfomer, when executed, will create and later joined one background thread.
public static InputStream asInputStream(InputStream delegate, ContentsTransformer transformer, String name)
InputStream
that reads from the delegate and through the
transformername
- Designates the contents that is transformed; may be used by the transformer e.g. to
decide how to transform the contentspublic static OutputStream asOutputStream(ContentsTransformer transformer, OutputStream delegate, String name)
OutputStream
that writes through the transformer and to the
delegate.name
- Designates the contents that is transformed; may be used by the transformer e.g. to
decide how to transform the contentsCopyright © 2018 Arno Unkrig. All rights reserved.