Package org.apache.commons.io.filefilter
Class AbstractFileFilter
java.lang.Object
org.apache.commons.io.filefilter.AbstractFileFilter
- All Implemented Interfaces:
FileFilter
,FilenameFilter
,FileVisitor<Path>
,PathFilter
,PathVisitor
,IOFileFilter
- Direct Known Subclasses:
AgeFileFilter
,AndFileFilter
,CanExecuteFileFilter
,CanReadFileFilter
,CanWriteFileFilter
,DelegateFileFilter
,DirectoryFileFilter
,EmptyFileFilter
,FileEqualsFileFilter
,FileFileFilter
,HiddenFileFilter
,MagicNumberFileFilter
,NameFileFilter
,NotFileFilter
,OrFileFilter
,PathEqualsFileFilter
,PathVisitorFileFilter
,PrefixFileFilter
,RegexFileFilter
,SizeFileFilter
,SuffixFileFilter
,SymbolicLinkFileFilter
,WildcardFileFilter
,WildcardFilter
Abstracts the implementation of the
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.
- Since:
- 1.0
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final FileVisitResult
What to do when this filter accepts.private final FileVisitResult
What to do when this filter rejects.Fields inherited from interface org.apache.commons.io.filefilter.IOFileFilter
EMPTY_STRING_ARRAY
-
Constructor Summary
ConstructorsModifierConstructorDescriptionConstructs a new instance.protected
AbstractFileFilter
(FileVisitResult onAccept, FileVisitResult onReject) Constructs a new instance. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Checks to see if the File should be accepted by this filter.boolean
Checks to see if the File should be accepted by this filter.(package private) void
append
(Object[] array, StringBuilder buffer) (package private) void
append
(List<?> list, StringBuilder buffer) (package private) FileVisitResult
get
(IOSupplier<FileVisitResult> supplier) protected FileVisitResult
Handles exceptions caught while accepting.postVisitDirectory
(Path dir, IOException exc) preVisitDirectory
(Path dir, BasicFileAttributes attributes) (package private) static FileVisitResult
toDefaultFileVisitResult
(boolean accept) (package private) FileVisitResult
toFileVisitResult
(boolean accept) Converts a boolean into a FileVisitResult.toString()
Provides a String representation of this file filter.visitFile
(Path file, BasicFileAttributes attributes) visitFileFailed
(Path file, IOException exc) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.apache.commons.io.filefilter.IOFileFilter
accept, and, negate, or
-
Field Details
-
onAccept
What to do when this filter accepts. -
onReject
What to do when this filter rejects.
-
-
Constructor Details
-
AbstractFileFilter
public AbstractFileFilter()Constructs a new instance. -
AbstractFileFilter
Constructs a new instance.- Parameters:
onAccept
- What to do on acceptance.onReject
- What to do on rejection.- Since:
- 2.12.0.
-
-
Method Details
-
toDefaultFileVisitResult
-
accept
Checks to see if the File should be accepted by this filter.- Specified by:
accept
in interfaceFileFilter
- Specified by:
accept
in interfaceIOFileFilter
- Parameters:
file
- the File to check- Returns:
- true if this file matches the test
-
accept
Checks to see if the File should be accepted by this filter.- Specified by:
accept
in interfaceFilenameFilter
- Specified by:
accept
in interfaceIOFileFilter
- Parameters:
dir
- the directory File to checkname
- the file name within the directory to check- Returns:
- true if this file matches the test
-
append
-
append
-
get
-
handle
Handles exceptions caught while accepting.- Parameters:
t
- the caught Throwable.- Returns:
- the given Throwable.
- Since:
- 2.9.0
-
postVisitDirectory
- Specified by:
postVisitDirectory
in interfaceFileVisitor<Path>
- Throws:
IOException
-
preVisitDirectory
public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attributes) throws IOException - Specified by:
preVisitDirectory
in interfaceFileVisitor<Path>
- Throws:
IOException
-
toFileVisitResult
Converts a boolean into a FileVisitResult.- Parameters:
accept
- accepted or rejected.- Returns:
- a FileVisitResult.
-
toString
Provides a String representation of this file filter. -
visitFile
- Specified by:
visitFile
in interfaceFileVisitor<Path>
- Throws:
IOException
-
visitFileFailed
- Specified by:
visitFileFailed
in interfaceFileVisitor<Path>
- Throws:
IOException
-