public interface FileTransformer
transform(String, File, File, Mode)
Modifier and Type | Interface and Description |
---|---|
static class |
FileTransformer.Mode |
Modifier and Type | Field and Description |
---|---|
static RuntimeException |
NOT_IDENTICAL
Thrown by
transform (String, File, File, FileTransformer.Mode.CHECK ) ; indicates that when that method would be invoked with mode FileTransformer.Mode.TRANSFORM , its output would not be identical with its input. |
static Runnable |
THROW_NOT_IDENTICAL
A
Runnable that simply throws NOT_IDENTICAL . |
Modifier and Type | Method and Description |
---|---|
void |
transform(String path,
File in,
File out,
FileTransformer.Mode mode)
Creates the file out, based on the file in.
|
static final RuntimeException NOT_IDENTICAL
transform
(String, File, File,
FileTransformer.Mode.CHECK
)
; indicates that when that method would be invoked with mode FileTransformer.Mode.TRANSFORM
, its output would not be identical with its input. That can only be the case for an
"in-place" transformation.static final Runnable THROW_NOT_IDENTICAL
Runnable
that simply throws NOT_IDENTICAL
.void transform(String path, File in, File out, FileTransformer.Mode mode) throws IOException
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:
mode == Mode.CHECK
, then this method merely checks whether the content of the file
would change, and, if so, complete normally, otherwise it would throw NOT_IDENTICAL
.
!
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.)
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>
path
- A text designating the input file; typically, but not necessarily identical with in.getPath()
in
- The input file to readout
- The output file to create; irrelevant iff mode ==
FileTransformer.Mode.CHECK
RuntimeException
- NOT_IDENTICAL
iff mode ==
FileTransformer.Mode.CHECK
and the output produced
by transform(String, File, File, Mode)
would not be identical with the inputIOException
NOT_IDENTICAL
,
FileTransformer.Mode.TRANSFORM
,
FileTransformer.Mode.CHECK
,
FileTransformer.Mode.CHECK_AND_TRANSFORM
Copyright © 2018 Arno Unkrig. All rights reserved.