se.hirt.plugin
Class FileScanner

java.lang.Object
  extended by se.hirt.plugin.FileScanner

public class FileScanner
extends java.lang.Object

Recursively scans the files of a directory. A user defined callback can be applied on each file encountered.

Author:
Marcus Hirt

Nested Class Summary
static interface FileScanner.FileApplier
          Callback interface to be used with the scanner.
 
Constructor Summary
FileScanner()
           
 
Method Summary
static java.util.Set<java.lang.Class> getClassesFromDir(java.lang.ClassLoader loader, java.io.File dir)
          Uses a FileApplier that goes through the entire directory looking for classes.
static void scanDirectory(java.io.File directory, FileScanner.FileApplier applier)
          Scans the files of the direcory, applying the applier to each file and directory encountered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileScanner

public FileScanner()
Method Detail

scanDirectory

public static void scanDirectory(java.io.File directory,
                                 FileScanner.FileApplier applier)
Scans the files of the direcory, applying the applier to each file and directory encountered.

Parameters:
directory - the directory to scan. This can also be a single file. If so the applier will be applied to that file only.
applier - the applier to apply to the file(s).

getClassesFromDir

public static java.util.Set<java.lang.Class> getClassesFromDir(java.lang.ClassLoader loader,
                                                               java.io.File dir)
Uses a FileApplier that goes through the entire directory looking for classes. The JarScanner will be used if any jar files are encountered.

Parameters:
loader - the loader which will be used to try to load the classes.
dir - the directory to search.
Returns:
the set of classes found.


Copyright © 2005 Marcus Hirt