public abstract class AbstractFileFilter extends Object implements IOFileFilter, PathVisitor
FileFilter (IO), FilenameFilter (IO), PathFilter (NIO)
interfaces via our own IOFileFilter interface.
Note that a subclass MUST override one of the accept methods, otherwise that subclass will infinitely loop.
EMPTY_STRING_ARRAY| Modifier | Constructor and Description |
|---|---|
|
AbstractFileFilter()
Constructs a new instance.
|
protected |
AbstractFileFilter(FileVisitResult onAccept,
FileVisitResult onReject)
Constructs a new instance.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(File file)
Tests to see if the File should be accepted by this filter.
|
boolean |
accept(File dir,
String name)
Tests to see if the File should be accepted by this filter.
|
(package private) void |
append(List<?> list,
StringBuilder buffer)
Append list to string builder.
|
(package private) void |
append(Object[] array,
StringBuilder buffer)
Append array to string builder.
|
(package private) FileVisitResult |
get(IOSupplier<FileVisitResult> supplier)
Get file visit result from supplier.
|
protected FileVisitResult |
handle(Throwable t)
Handles exceptions caught while accepting.
|
(package private) boolean |
isDirectory(File file)
Check if file is a directory.
|
(package private) boolean |
isFile(File file)
Check if file is a regular file.
|
FileVisitResult |
postVisitDirectory(Path dir,
IOException exc) |
FileVisitResult |
preVisitDirectory(Path dir,
BasicFileAttributes attributes) |
(package private) static FileVisitResult |
toDefaultFileVisitResult(boolean accept)
Convert boolean to default file visit result.
|
(package private) FileVisitResult |
toFileVisitResult(boolean accept)
Converts a boolean into a FileVisitResult.
|
String |
toString()
Provides a String representation of this file filter.
|
FileVisitResult |
visitFile(Path file,
BasicFileAttributes attributes) |
FileVisitResult |
visitFileFailed(Path file,
IOException exc) |
public AbstractFileFilter()
protected AbstractFileFilter(FileVisitResult onAccept, FileVisitResult onReject)
onAccept - What to do on acceptance.onReject - What to do on rejection.public boolean accept(File file)
accept in interface FileFilteraccept in interface IOFileFilterfile - the File to checkpublic boolean accept(File dir, String name)
accept in interface FilenameFilteraccept in interface IOFileFilterdir - the directory File to checkname - the file name within the directory to checkvoid append(List<?> list, StringBuilder buffer)
list - the list to appendbuffer - the string builder to append tovoid append(Object[] array, StringBuilder buffer)
array - the array to appendbuffer - the string builder to append toFileVisitResult get(IOSupplier<FileVisitResult> supplier)
supplier - the supplier to get the result fromprotected FileVisitResult handle(Throwable t)
t - the caught Throwable.boolean isDirectory(File file)
file - the file to checkboolean isFile(File file)
file - file to checkpublic FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException
postVisitDirectory in interface FileVisitor<Path>IOExceptionpublic FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attributes) throws IOException
preVisitDirectory in interface FileVisitor<Path>IOExceptionstatic FileVisitResult toDefaultFileVisitResult(boolean accept)
accept - the boolean value to convertFileVisitResult toFileVisitResult(boolean accept)
accept - accepted or rejected.public String toString()
public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException
visitFile in interface FileVisitor<Path>IOExceptionpublic FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException
visitFileFailed in interface FileVisitor<Path>IOException