public class DeletingVisitor extends SimpleFileVisitor<Path>
Constructor and Description |
---|
DeletingVisitor(Path basePath,
List<? extends PathCondition> pathConditions,
boolean testMode)
Constructs a new DeletingVisitor.
|
Modifier and Type | Method and Description |
---|---|
protected void |
delete(Path file)
Deletes the specified file.
|
boolean |
isTestMode()
Returns
true if files are not deleted even when all conditions accept a path, false otherwise. |
FileVisitResult |
visitFile(Path file,
BasicFileAttributes attrs) |
postVisitDirectory, preVisitDirectory, visitFileFailed
public DeletingVisitor(Path basePath, List<? extends PathCondition> pathConditions, boolean testMode)
basePath
- used to relativize pathspathConditions
- objects that need to confirm whether a file can be deletedtestMode
- if true, files are not deleted but instead a message is printed to the status logger
at INFO level. Users can use this to do a dry run to test if their configuration works as expected.public FileVisitResult visitFile(Path file, BasicFileAttributes attrs) throws IOException
visitFile
in interface FileVisitor<Path>
visitFile
in class SimpleFileVisitor<Path>
IOException
protected void delete(Path file) throws IOException
file
- the file to deleteIOException
- if a problem occurred deleting the filepublic boolean isTestMode()
true
if files are not deleted even when all conditions accept a path, false
otherwise.true
if files are not deleted even when all conditions accept a path, false
otherwiseCopyright © 1999-2017. All Rights Reserved.
Apache Logging, Apache Log4j, Log4j, Apache, the Apache feather logo, the Apache Logging project logo, and the Apache Log4j logo are trademarks of The Apache Software Foundation.