Class ResourceWalker

java.lang.Object
org.apache.commons.io.DirectoryWalker<String>
clazzfish.monitor.internal.ResourceWalker
Direct Known Subclasses:
ClassWalker

public class ResourceWalker extends org.apache.commons.io.DirectoryWalker<String>
This class scans a sub directory for a given suffix. Originally it was part of the PatternTesting project.
Author:
oliver
  • Nested Class Summary

    Nested classes/interfaces inherited from class org.apache.commons.io.DirectoryWalker

    org.apache.commons.io.DirectoryWalker.CancelException
  • Constructor Summary

    Constructors
    Constructor
    Description
    Instantiates a new Resource walker for all resources.
    Instantiates a new Resource walker.
    ResourceWalker(File dir, String suffix)
    Instantiates a new resource walker for resources with the given suffix.
  • Method Summary

    Modifier and Type
    Method
    Description
    Walk thru the directories and return it as packages.
    Walk thru the directories and return all found file resources.
    protected boolean
    handleDirectory(File directory, int depth, Collection<String> results)
    Overridable callback method invoked to determine if a directory should be processed.
    protected void
    handleFile(File file, int depth, Collection<String> results)
    Handle file.

    Methods inherited from class org.apache.commons.io.DirectoryWalker

    checkIfCancelled, filterDirectoryContents, handleCancelled, handleDirectoryEnd, handleDirectoryStart, handleEnd, handleIsCancelled, handleRestricted, handleStart, walk

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ResourceWalker

      public ResourceWalker(File dir)
      Instantiates a new Resource walker for all resources.
      Parameters:
      dir - the start dir
    • ResourceWalker

      public ResourceWalker(File dir, String suffix)
      Instantiates a new resource walker for resources with the given suffix.
      Parameters:
      dir - the start dir
      suffix - file suffix, e.g. ".xml"
    • ResourceWalker

      public ResourceWalker(File dir, FileFilter filter)
      Instantiates a new Resource walker.
      Parameters:
      dir - the dir
      filter - the filter
  • Method Details

    • getResources

      public Collection<String> getResources() throws IOException
      Walk thru the directories and return all found file resources.
      Returns:
      a collection of resources
      Throws:
      IOException - Signals that an I/O exception has occurred.
    • getPackages

      public Collection<String> getPackages() throws IOException
      Walk thru the directories and return it as packages.
      Returns:
      the packages
      Throws:
      IOException - the io exception
    • handleFile

      protected void handleFile(File file, int depth, Collection<String> results) throws IOException
      Handle file.
      Overrides:
      handleFile in class org.apache.commons.io.DirectoryWalker<String>
      Parameters:
      file - the file
      depth - the depth
      results - the results
      Throws:
      IOException - Signals that an I/O exception has occurred.
      See Also:
      • DirectoryWalker.handleFile(File, int, Collection)
    • handleDirectory

      protected boolean handleDirectory(File directory, int depth, Collection<String> results) throws IOException
      Overridable callback method invoked to determine if a directory should be processed.
      Overrides:
      handleDirectory in class org.apache.commons.io.DirectoryWalker<String>
      Parameters:
      directory - the current directory being processed
      depth - the current directory level (starting directory = 0)
      results - the collection of result objects, may be updated
      Returns:
      true to process this directory
      Throws:
      IOException - if an I/O Error occurs