Skip to content

Instantly share code, notes, and snippets.

@struberg
Created August 29, 2012 09:06
Show Gist options
  • Save struberg/3508860 to your computer and use it in GitHub Desktop.
Save struberg/3508860 to your computer and use it in GitHub Desktop.
package org.apache.maven.shared.utils.io;
import java.io.File;
/**
* <p>Visitor pattern for the DirectoryScanner. A ScanConductor controls the scanning process.</p>
*
* <p>Create an instance and pass it to {@link org.apache.maven.shared.utils.io.DirectoryScanner#scan(ScanConductor)}.
* You will get notified about every visited directory and file. You can use the {@link ScanAction}
* to control what should happen next.</p>
*
* @author <a href="mailto:struberg@apache.org">Mark Struberg</a>
*/
public interface ScanConductor
{
public enum ScanAction
{
/**
* Abort the whole scanning.
*/
ABORT,
/**
* Continue with the scanning
*/
CONTINUE,
/**
* This response is only valid for {@link ScanConductor#visitDirectory(java.io.File)}.
* Do not recurse into the current directory.
*/
NO_RECURSE,
/**
* Abort the scanning of the current directory
*/
ABORT_DIRECTORY
}
/**
* This method will get invoked for every detected directory.
*
* @param directory
* @return the ScanAction to control how to proceed with the scanning
*/
ScanAction visitDirectory(File directory);
/**
* This method will get invoked for every detected file.
*
* @param file
* @return the ScanAction to control how to proceed with the scanning
*/
ScanAction visitFile(File file);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment