com.darwinsys.io
Class Crawler

java.lang.Object
  extended by com.darwinsys.io.Crawler
All Implemented Interfaces:
Checkpointer

public class Crawler
extends java.lang.Object
implements Checkpointer

Simple directory crawler, using a Filename Filter to select files and the Visitor pattern to process each chosen file. See the regression test CrawlerTest for a working example. XXX Lots of things are static that should not be!!

Version:
$Id: Crawler.java,v 1.31 2007/09/24 19:41:25 ian Exp $
Author:
Ian Darwin, http://www.darwinsys.com/

Field Summary
static CrawlerCallback JUST_PRINT
          An Error Handler that just prints the exception
 
Constructor Summary
Crawler(java.io.FilenameFilter chooser, FileHandler fileVisitor)
           
 
Method Summary
 void addExcludeDirs(java.lang.String... dirs)
          Add a list of directories that should be excluded in crawling.
 void crawl(java.io.File startDir)
          Crawl one set of directories, starting at startDir.
 CrawlerCallback getEHandler()
           
static FileHandler getVisitor()
           
static boolean isDebug()
           
 boolean isVerbose()
           
 void setEHandler(CrawlerCallback handler)
           
 void setVerbose(boolean verbose)
           
static void setVisitor(FileHandler visitor)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JUST_PRINT

public static final CrawlerCallback JUST_PRINT
An Error Handler that just prints the exception

Constructor Detail

Crawler

public Crawler(java.io.FilenameFilter chooser,
               FileHandler fileVisitor)
Method Detail

crawl

public void crawl(java.io.File startDir)
           throws java.io.IOException
Crawl one set of directories, starting at startDir. Calls itself recursively.

Parameters:
startDir -
Throws:
java.io.IOException - if File.getCanonicalPath() does so.

getEHandler

public CrawlerCallback getEHandler()

setEHandler

public void setEHandler(CrawlerCallback handler)

isVerbose

public boolean isVerbose()

setVerbose

public void setVerbose(boolean verbose)

isDebug

public static boolean isDebug()

getVisitor

public static FileHandler getVisitor()

setVisitor

public static void setVisitor(FileHandler visitor)

addExcludeDirs

public void addExcludeDirs(java.lang.String... dirs)
Add a list of directories that should be excluded in crawling.

Parameters:
dirs -


Copyright © 1996-2004 Ian F. Darwin. See license.html for usage license.