de.unkrig.commons.file.filetransformation
Class ProxyFileTransformer
java.lang.Object
de.unkrig.commons.file.filetransformation.ProxyFileTransformer
- All Implemented Interfaces:
- FileTransformer
public class ProxyFileTransformer
- extends java.lang.Object
- implements FileTransformer
A file transformer which delegates to the file transformer specified by set(FileTransformer).
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
ProxyFileTransformer
public ProxyFileTransformer()
transform
public void transform(java.lang.String path,
java.io.File in,
java.io.File out,
FileTransformer.Mode mode)
throws java.io.IOException
- Description copied from interface:
FileTransformer
- Creates the file
out, based on the file in. Iff in.equals(out) ('in-place
transformation'), then the original file remains unchanged, is modified, or replaced with a new file.
The precise contract is as follows:
-
If
mode == Mode.CHECK, then this method merely checks whether the file would be
changed, and, if so, completes normally, otherwise it throws FileTransformer.NOT_IDENTICAL. (Parameter out
is ignored.)
-
Otherwise, if
!in.equals(out) ('out-of-place transformation'), out is created, based
on in. (Parameter mode is ignored.) (If this method throws an exception, then it must not
leave a file out behind.)
-
Otherwise, the file is left unchanged, is modified, or is replaced with a new file. If
mode ==
Mode.CHECK_AND_TRANSFORM, then the method attempts to avoid unnecessary i/o and processing by first checking
whether the file requires any modifications before applying them. (If this method throws an exception, then
it must revert the file to its original state as far as is reasonably possible.)
/li>
- 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
set
public void set(FileTransformer delegate)
- See Also:
ProxyFileTransformer