Author: scolebourne
Date: Tue Aug 29 14:15:11 2006
New Revision: 438218
URL: http://svn.apache.org/viewvc?rev=438218&view=rev
Log:
Separate handleDirectory from handleDirectoryStart
Modified:
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/DirectoryWalker.java
jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/DirectoryWalkerTestCase.java
Modified:
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/DirectoryWalker.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/DirectoryWalker.java?rev=438218&r1=438217&r2=438218&view=diff
==============================================================================
---
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/DirectoryWalker.java
(original)
+++
jakarta/commons/proper/io/trunk/src/java/org/apache/commons/io/DirectoryWalker.java
Tue Aug 29 14:15:11 2006
@@ -91,7 +91,7 @@
//-----------------------------------------------------------------------
/**
- * Internal method that walks the directory hierarchy.
+ * Internal method that walks the directory hierarchy in a depth-first
manner.
* <p>
* Most users of this class do not need to call this method. This method
will
* be called automatically by another (public) method on the specific
subclass.
@@ -117,13 +117,13 @@
* @param results the collection of result objects, may be updated
*/
private void walk(File directory, int depth, Collection results) {
- boolean process = handleDirectoryStart(directory, depth, results);
- if (process) {
+ if (handleDirectory(directory, depth, results)) {
+ handleDirectoryStart(directory, depth, results);
int childDepth = depth + 1;
if (depthLimit < 0 || childDepth <= depthLimit) {
File[] files = (filter == null ? directory.listFiles() :
directory.listFiles(filter));
if (files == null) {
- handleRestricted(directory);
+ handleRestricted(directory, results);
} else {
for (int i = 0; i < files.length; i++) {
if (files[i].isDirectory()) {
@@ -152,12 +152,11 @@
}
/**
- * Overridable callback method invoked at the start of processing each
directory.
+ * Overridable callback method invoked to determine if a directory should
be processed.
* <p>
- * This method returns a boolean to indicate if the directory should be
examined
- * or not. If you return false, the next event received will be the
- * [EMAIL PROTECTED] #handleDirectoryEnd} for that directory. Note that
this functionality
- * is in addition to the filtering by file filter.
+ * This method returns a boolean to indicate if the directory should be
examined or not.
+ * If you return false, the entire directory and any subdirectories will
be skipped.
+ * Note that this functionality is in addition to the filtering by file
filter.
* <p>
* This implementation does nothing and returns true.
*
@@ -166,12 +165,25 @@
* @param results the collection of result objects, may be updated
* @return true to process this directory, false to skip this directory
*/
- protected boolean handleDirectoryStart(File directory, int depth,
Collection results) {
+ protected boolean handleDirectory(File directory, int depth, Collection
results) {
// do nothing - overridable by subclass
return true;
}
/**
+ * Overridable callback method invoked at the start of processing each
directory.
+ * <p>
+ * This implementation does nothing.
+ *
+ * @param directory the current directory being processed
+ * @param depth the current directory level (starting directory = 0)
+ * @param results the collection of result objects, may be updated
+ */
+ protected void handleDirectoryStart(File directory, int depth, Collection
results) {
+ // do nothing - overridable by subclass
+ }
+
+ /**
* Overridable callback method invoked for each (non-directory) file.
* <p>
* This implementation does nothing.
@@ -186,10 +198,13 @@
/**
* Overridable callback method invoked for each restricted directory.
+ * <p>
+ * This implementation does nothing.
*
* @param directory the restricted directory
+ * @param results the collection of result objects, may be updated
*/
- protected void handleRestricted(File directory) {
+ protected void handleRestricted(File directory, Collection results) {
// do nothing - overridable by subclass
}
@@ -198,9 +213,9 @@
* <p>
* This implementation does nothing.
*
- * @param directory The directory being processed
- * @param depth The directory level (starting directory = 0)
- * @param results The collection of files found.
+ * @param directory the directory being processed
+ * @param depth the current directory level (starting directory = 0)
+ * @param results the collection of result objects, may be updated
*/
protected void handleDirectoryEnd(File directory, int depth, Collection
results) {
// do nothing - overridable by subclass
Modified:
jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/DirectoryWalkerTestCase.java
URL:
http://svn.apache.org/viewvc/jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/DirectoryWalkerTestCase.java?rev=438218&r1=438217&r2=438218&view=diff
==============================================================================
---
jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/DirectoryWalkerTestCase.java
(original)
+++
jakarta/commons/proper/io/trunk/src/test/org/apache/commons/io/DirectoryWalkerTestCase.java
Tue Aug 29 14:15:11 2006
@@ -247,7 +247,7 @@
}
/** Always returns false. */
- protected boolean handleDirectoryStart(File directory, int depth,
Collection results) {
+ protected boolean handleDirectory(File directory, int depth,
Collection results) {
return false;
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]