Class FileVisitor

java.lang.Object
eu.bandm.tools.util.files.FileVisitor
Direct Known Subclasses:
FileTree.Visitor

public class FileVisitor extends Object
Applies visitor style pattern to file system trees.
  • Field Details

    • errorHandler

      protected final Consumer<String> errorHandler
      Receives a string in cases of errors.
  • Constructor Details

    • FileVisitor

      public FileVisitor()
      Constructor which uses System.err as an error handler.
    • FileVisitor

      public FileVisitor(Consumer<String> errorHandler)
      Constructor which uses an explicit error handler.
      Parameters:
      errorHandler - where to send error messages (as strings)
  • Method Details

    • visit

      public void visit(File f)
      Central entry method.
      Is called for applying the visitor. Normally it will not be overwritten. Calls directly visitNonDir(File) or visitDir(File), depending on the type of the file.
      Parameters:
      f - position in the file system from which visiting shall descend.
    • visitDir_pre

      public void visitDir_pre(File f)
      To be overwritten by payload code, if wanted. Is called for every directory before descending into the contained files.
      Parameters:
      f - the directory to visit
    • visitDir_post

      public void visitDir_post(File f)
      To be overwritten by payload code, if wanted. Is called for every directory after descending into the contained files.
      Parameters:
      f - the directory to visit
    • visitNonDir

      public void visitNonDir(File f)
      To be overwritten by payload code, if wanted. Is called for every non-directory file.
      Parameters:
      f - the non-directory file to visit