Package org.apache.commons.io.filefilter

# Class AbstractFileFilter

java.lang.Object
org.apache.commons.io.filefilter.AbstractFileFilter

All Implemented Interfaces:
  `FileFilter`, `FilenameFilter`, `FileVisitor<Path>`, `PathMatcher`, `PathFilter`, `PathVisitor`, `IOFileFilter`

Direct Known Subclasses:
  `AgeFileFilter`, `AndFileFilter`, `CanExecuteFileFilter`, `CanReadFileFilter`, `CanWriteFileFilter`, `DelegateFileFilter`, `DirectoryFileFilter`, `EmptyFileFilter`, `FileEqualsFileFilter`, `FileFileFilter`, `HiddenFileFilter`, `MagicNumberFileFilter`, `NameFileFilter`, `NotFileFilter`, `OrFileFilter`, `PathEqualsFileFilter`, `PathMatcherFileFilter`, `PathVisitorFileFilter`, `PrefixFileFilter`, `RegexFileFilter`, `SizeFileFilter`, `SuffixFileFilter`, `SymbolicLinkFileFilter`, `WildcardFileFilter`, `WildcardFilter`

public abstract class AbstractFileFilter extends Object implements IOFileFilter, PathVisitor
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

  ### Fields inherited from interface org.apache.commons.io.filefilter.IOFileFilter

  `EMPTY_STRING_ARRAY`

- ## Constructor Summary

  Constructors
  Modifier
  Constructor
  Description
  ``
  `AbstractFileFilter()`
  Constructs a new instance.
  `protected`
  `AbstractFileFilter(FileVisitResult onAccept, FileVisitResult onReject)`
  Constructs a new instance.

- ## Method Summary

  Modifier and Type
  Method
  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.
  `protected FileVisitResult`
  `handle(Throwable t)`
  Handles exceptions caught while accepting.
  `FileVisitResult`
  `postVisitDirectory(Path dir, IOException exc)`
  `FileVisitResult`
  `preVisitDirectory(Path dir, BasicFileAttributes attributes)`
  `String`
  `toString()`
  Provides a String representation of this file filter.
  `FileVisitResult`
  `visitFile(Path file, BasicFileAttributes attributes)`
  `FileVisitResult`
  `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, matches, negate, or`

- ## Constructor Details

  - ### AbstractFileFilter

    public AbstractFileFilter()
    Constructs a new instance.

  - ### AbstractFileFilter

    protected AbstractFileFilter(FileVisitResult onAccept, FileVisitResult onReject)
    Constructs a new instance.
    Parameters:
      `onAccept` - What to do on acceptance.
      `onReject` - What to do on rejection.
    Since:
      2.12.0.

- ## Method Details

  - ### accept

    public boolean accept(File file)
    Tests to see if the File should be accepted by this filter.
    Specified by:
      `accept` in interface `FileFilter`
    Specified by:
      `accept` in interface `IOFileFilter`
    Parameters:
      `file` - the File to check
    Returns:
      true if this file matches the test

  - ### accept

    public boolean accept(File dir, String name)
    Tests to see if the File should be accepted by this filter.
    Specified by:
      `accept` in interface `FilenameFilter`
    Specified by:
      `accept` in interface `IOFileFilter`
    Parameters:
      `dir` - the directory File to check
      `name` - the file name within the directory to check
    Returns:
      true if this file matches the test

  - ### handle

    protected FileVisitResult handle(Throwable t)
    Handles exceptions caught while accepting.
    Parameters:
      `t` - the caught Throwable.
    Returns:
      the given Throwable.
    Since:
      2.9.0

  - ### postVisitDirectory

    public FileVisitResult postVisitDirectory(Path dir, IOException exc) throws IOException
    Specified by:
      `postVisitDirectory` in interface `FileVisitor<Path>`
    Throws:
      `IOException`

  - ### preVisitDirectory

    public FileVisitResult preVisitDirectory(Path dir, BasicFileAttributes attributes) throws IOException
    Specified by:
      `preVisitDirectory` in interface `FileVisitor<Path>`
    Throws:
      `IOException`

  - ### toString

    public String toString()
    Provides a String representation of this file filter.
    Overrides:
      `toString` in class `Object`
    Returns:
      a String representation

  - ### visitFile

    public FileVisitResult visitFile(Path file, BasicFileAttributes attributes) throws IOException
    Specified by:
      `visitFile` in interface `FileVisitor<Path>`
    Throws:
      `IOException`

  - ### visitFileFailed

    public FileVisitResult visitFileFailed(Path file, IOException exc) throws IOException
    Specified by:
      `visitFileFailed` in interface `FileVisitor<Path>`
    Throws:
      `IOException`