it.geosolutions.tools.io.file
Class Collector

java.lang.Object
  extended by org.apache.commons.io.DirectoryWalker<File>
      extended by it.geosolutions.tools.io.file.Collector

public class Collector
extends org.apache.commons.io.DirectoryWalker<File>

A collector which wraps the DirectoryWalker to define a Collector which is able to collect (recursively) a set of file starting from a base dir applying a FileFilter

Author:
Carlo Cancellieri - carlo.cancellieri@geo-solutions.it

Nested Class Summary
 
Nested classes/interfaces inherited from class org.apache.commons.io.DirectoryWalker
org.apache.commons.io.DirectoryWalker.CancelException
 
Constructor Summary
Collector(FileFilter filter)
           
Collector(FileFilter filter, int deep)
           
 
Method Summary
 List<File> collect(File root)
           
protected  File[] filterDirectoryContents(File directory, int depth, File[] files)
           
protected  boolean handleDirectory(File directory, int depth, Collection<File> results)
           
protected  void handleFile(File file, int depth, Collection<File> results)
           
 void setFilter(FileFilter filter)
          Set a new filter for this collector.
 
Methods inherited from class org.apache.commons.io.DirectoryWalker
checkIfCancelled, 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 Detail

Collector

public Collector(FileFilter filter)

Collector

public Collector(FileFilter filter,
                 int deep)
Parameters:
filter - the filter to apply, null means visit all files
deep - controls how deep the hierarchy is navigated to (less than 0 means unlimited)
Method Detail

setFilter

public void setFilter(FileFilter filter)
Set a new filter for this collector. (can be null)

Parameters:
filter -

collect

public List<File> collect(File root)
Parameters:
root -
Returns:
list of file (can be empty)
Throws:
IOException

handleDirectory

protected boolean handleDirectory(File directory,
                                  int depth,
                                  Collection<File> results)
                           throws IOException
Overrides:
handleDirectory in class org.apache.commons.io.DirectoryWalker<File>
Throws:
IOException

filterDirectoryContents

protected File[] filterDirectoryContents(File directory,
                                         int depth,
                                         File[] files)
                                  throws IOException
Overrides:
filterDirectoryContents in class org.apache.commons.io.DirectoryWalker<File>
Throws:
IOException

handleFile

protected void handleFile(File file,
                          int depth,
                          Collection<File> results)
                   throws IOException
Overrides:
handleFile in class org.apache.commons.io.DirectoryWalker<File>
Throws:
IOException


Copyright © 2011-2012 GeoSolutions. All Rights Reserved.