|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectde.unkrig.commons.file.fileprocessing.FileProcessings
public final class FileProcessings
Various file processing utility methods.
| Nested Class Summary | |
|---|---|
static interface |
FileProcessings.DirectoryCombiner<T>
Transforms the return values of the invocations of directoryMemberProcessor for each member. |
| Method Summary | ||
|---|---|---|
static
|
archiveCompressedAndNormalFileProcessor(Predicate<java.lang.String> lookIntoFormat,
ContentsProcessor<T> archiveContentsProcessor,
ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner,
ContentsProcessor<T> compressedContentsProcessor,
ContentsProcessor<T> normalContentsProcessor,
ExceptionHandler<java.io.IOException> exceptionHandler)
Returns a FileProcessor which processes files by feeding their contents either to the archiveContentsProcessor, the compressedContentsProcessor or the normalContentsProcessor}. |
|
static
|
directoryProcessor(Predicate<java.lang.String> pathPredicate,
FileProcessor<T> regularFileProcessor,
java.util.Comparator<java.lang.Object> directoryMemberNameComparator,
FileProcessor<T> directoryMemberProcessor,
FileProcessings.DirectoryCombiner<T> directoryCombiner,
SquadExecutor<java.lang.Void> squadExecutor,
ExceptionHandler<java.io.IOException> exceptionHandler)
Returns a FileProcessor which processes directories and regular files. |
|
static
|
directoryTreeProcessor(Predicate<java.lang.String> pathPredicate,
FileProcessor<T> regularFileProcessor,
java.util.Comparator<java.lang.Object> directoryMemberNameComparator,
FileProcessings.DirectoryCombiner<T> directoryCombiner,
SquadExecutor<java.lang.Void> squadExecutor,
ExceptionHandler<java.io.IOException> exceptionHandler)
Returns a FileProcessor which processes directories and regular files exactly like the FileProcessor returned by directoryProcessor(Predicate, FileProcessor, Comparator, FileProcessor,
DirectoryCombiner, SquadExecutor, ExceptionHandler), except that it processes directory members
recursively. |
|
static
|
nop()
|
|
static
|
nopDirectoryCombiner()
A FileProcessings.DirectoryCombiner which ignores the combinables and returns null. |
|
static
|
process(java.util.List<java.io.File> files,
FileProcessor<T> fileProcessor)
|
|
static
|
process(java.util.List<java.io.File> files,
FileProcessor<T> fileProcessor,
ExceptionHandler<java.io.IOException> exceptionHandler)
Invokes the fileProcessor for each of the files. |
|
static
|
recursiveCompressedAndArchiveFileProcessor(Predicate<java.lang.String> lookIntoFormat,
ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner,
ContentsProcessor<T> delegate,
ExceptionHandler<java.io.IOException> exceptionHandler)
Returns a FileProcessor which processes files by feeding their contents through the delegate
(just like the FileContentsProcessor), but automagically detects various archive and compression formats
(also nested) and processes the entries of the archive and the uncompressed contents instead of
the "raw" contents. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static <T> FileProcessor<T> nop()
FileProcessor that does nothing.
public static <T> void process(java.util.List<java.io.File> files,
FileProcessor<T> fileProcessor)
throws java.io.IOException
java.io.IOExceptionprocess(List, FileProcessor, ExceptionHandler)
public static <T> void process(java.util.List<java.io.File> files,
FileProcessor<T> fileProcessor,
ExceptionHandler<java.io.IOException> exceptionHandler)
throws java.io.IOException
fileProcessor for each of the files.
exceptionHandler - Called if the processing of one of the inputFiles throws an IOException
or a RuntimeException
java.io.IOException
public static <T> FileProcessor<T> directoryTreeProcessor(Predicate<java.lang.String> pathPredicate,
FileProcessor<T> regularFileProcessor,
@Nullable
java.util.Comparator<java.lang.Object> directoryMemberNameComparator,
FileProcessings.DirectoryCombiner<T> directoryCombiner,
SquadExecutor<java.lang.Void> squadExecutor,
ExceptionHandler<java.io.IOException> exceptionHandler)
FileProcessor which processes directories and regular files exactly like the FileProcessor returned by directoryProcessor(Predicate, FileProcessor, Comparator, FileProcessor,
DirectoryCombiner, SquadExecutor, ExceptionHandler), except that it processes directory members
recursively.
directoryMemberNameComparator - The comparator used to sort a directory's members; a null value
means to NOT sort the members, i.e. leave them in their 'natural' order as
File.list() returns themdirectoryProcessor(Predicate, FileProcessor, Comparator, FileProcessor,
DirectoryCombiner, SquadExecutor, ExceptionHandler)
public static <T> FileProcessor<T> directoryProcessor(Predicate<java.lang.String> pathPredicate,
FileProcessor<T> regularFileProcessor,
@Nullable
java.util.Comparator<java.lang.Object> directoryMemberNameComparator,
FileProcessor<T> directoryMemberProcessor,
FileProcessings.DirectoryCombiner<T> directoryCombiner,
SquadExecutor<java.lang.Void> squadExecutor,
ExceptionHandler<java.io.IOException> exceptionHandler)
FileProcessor which processes directories and regular files.
Its behavior is as follows:
regularFileProcessor is invoked and its result is
returned.
pathPredicate, the directory can impossibly contain relevant documents,
null is returned.
directoryMemberNameComparator is not null, the members are sorted according to
the directoryMemberNameComparator
directoryMemberProcessor is invoked for each member, and the return values are stored in a
list.
directoryCombiner is invoked with that list,directoryCombiner is returned.pathPredicate is only used to avoid unnecessary directory scans; apart from that the
regularFileProcessor and the directoryMemberProcessor are called for any file without
further ado.
If you use Void for <T>, then nopDirectoryCombiner() is the right directoryCombiner.
T - The return type of all FileProcessor.process(String, File) methodsdirectoryMemberNameComparator - The comparator used to sort a directory's members; a null value
means to NOT sort the members, i.e. leave them in their 'natural' order as
File.list() returns thempublic static <T> FileProcessings.DirectoryCombiner<T> nopDirectoryCombiner()
FileProcessings.DirectoryCombiner which ignores the combinables and returns null.
public static <T> FileProcessor<T> archiveCompressedAndNormalFileProcessor(Predicate<java.lang.String> lookIntoFormat,
ContentsProcessor<T> archiveContentsProcessor,
ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner,
ContentsProcessor<T> compressedContentsProcessor,
ContentsProcessor<T> normalContentsProcessor,
ExceptionHandler<java.io.IOException> exceptionHandler)
FileProcessor which processes files by feeding their contents either to the archiveContentsProcessor, the compressedContentsProcessor or the normalContentsProcessor}.
Archive files and compressed files are introspected iff lookIntoFormat evaluates true for
"format:path".
lookIntoFormat - See CompressUtil.processFile(String, File, Predicate, ArchiveHandler,
CompressorHandler, NormalContentsHandler)
public static <T> FileProcessor<T> recursiveCompressedAndArchiveFileProcessor(Predicate<java.lang.String> lookIntoFormat,
ContentsProcessings.ArchiveCombiner<T> archiveEntryCombiner,
ContentsProcessor<T> delegate,
ExceptionHandler<java.io.IOException> exceptionHandler)
FileProcessor which processes files by feeding their contents through the delegate
(just like the FileContentsProcessor), but automagically detects various archive and compression formats
(also nested) and processes the entries of the archive and the uncompressed contents instead of
the "raw" contents.
Archive files/entries and compressed files/entries are introspected iff lookIntoFormat evaluates true for "format:path".
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||