de.unkrig.commons.file.filetransformation
Class DirectoryTransformer
java.lang.Object
de.unkrig.commons.file.filetransformation.DirectoryTransformer
- All Implemented Interfaces:
- FileTransformer
public class DirectoryTransformer
- extends java.lang.Object
- implements FileTransformer
- See Also:
transform(String, File, File, de.unkrig.commons.file.filetransformation.FileTransformer.Mode)
|
Method Summary |
java.lang.String |
toString()
|
void |
transform(java.lang.String path,
java.io.File in,
java.io.File out,
FileTransformer.Mode mode)
If in is not a directory, then the regularFileTransformer is invoked. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
DEFAULT_MEMBER_NAME_COMPARATOR
public static final java.text.Collator DEFAULT_MEMBER_NAME_COMPARATOR
- Sorts ascendingly by name (for the default locale).
A good default value for the memberNameComparator parameter of DirectoryTransformer(FileTransformer, Comparator, FileTransformer, FileTransformations.DirectoryCombiner,
ExceptionHandler).
- See Also:
DirectoryTransformer(FileTransformer, Comparator, FileTransformer, FileTransformations.DirectoryCombiner,
ExceptionHandler)
DirectoryTransformer
public DirectoryTransformer(FileTransformer regularFileTransformer,
@Nullable
java.util.Comparator<java.lang.Object> directoryMemberNameComparator,
FileTransformer directoryMemberTransformer,
FileTransformations.DirectoryCombiner directoryCombiner,
ExceptionHandler<java.io.IOException> exceptionHandler)
- Parameters:
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 them- See Also:
FileTransformer.transform(String, File, File, Mode),
DEFAULT_MEMBER_NAME_COMPARATOR
transform
public void transform(java.lang.String path,
java.io.File in,
java.io.File out,
FileTransformer.Mode mode)
throws java.io.IOException
- If
in is not a directory, then the regularFileTransformer is invoked.
Otherwise, out is taken as a directory (created if missing), and memberTransformer.transform() is called for each member of in. If that throws
an IOException or a RuntimeException, then that exception is caught, and exceptionHandler.handle() is called. If that method completes normally (i.e. it
doesn't throw an exception), then processing continues with the next member of directory in.
- Specified by:
transform in interface FileTransformer
- Parameters:
path - A text designating the input file; typically, but not necessarily identical with in.getPath()
- Throws:
java.io.IOException- See Also:
FileTransformer.NOT_IDENTICAL,
FileTransformer.Mode.TRANSFORM,
FileTransformer.Mode.CHECK,
FileTransformer.Mode.CHECK_AND_TRANSFORM
toString
public java.lang.String toString()
- Overrides:
toString in class java.lang.Object