Package org.marketcetera.util.file
Class SmartLinksDirectoryWalker
- java.lang.Object
-
- org.apache.commons.io.DirectoryWalker<String>
-
- org.marketcetera.util.file.SmartLinksDirectoryWalker
-
- Direct Known Subclasses:
Deleter.RecursiveDeleter
public abstract class SmartLinksDirectoryWalker extends org.apache.commons.io.DirectoryWalker<String>
ADirectoryWalkerwhich provides convenience methods to initiate traversal, and (optionally) does not follow symbolic links.
-
-
Field Summary
Fields Modifier and Type Field Description private booleanmFollowLinks
-
Constructor Summary
Constructors Modifier Constructor Description protectedSmartLinksDirectoryWalker(boolean followLinks)Constructor mirroring superclass constructor.protectedSmartLinksDirectoryWalker(boolean followLinks, FileFilter filter, int depthLimit)Constructor mirroring superclass constructor.protectedSmartLinksDirectoryWalker(boolean followLinks, org.apache.commons.io.filefilter.IOFileFilter directoryFilter, org.apache.commons.io.filefilter.IOFileFilter fileFilter, int depthLimit)Constructor mirroring superclass constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapply(File root)Traverses the file tree rooted at the given root.voidapply(File root, Collection<String> results)Traverses the file tree rooted at the given root.voidapply(String name)Traverses the file tree rooted at the file with the given name.voidapply(String name, Collection<String> results)Traverses the file tree rooted at the file with the given name.booleangetFollowLinks()Returns true if symbolic links to directories should be followed during traversal.protected booleanhandleDirectory(File directory, int depth, Collection<String> results)Returns false if the given directory is a symbolic link to a directory, and links are not to be followed, thereby blocking following the link during traversal.
-
-
-
Constructor Detail
-
SmartLinksDirectoryWalker
protected SmartLinksDirectoryWalker(boolean followLinks)
Constructor mirroring superclass constructor.- Parameters:
followLinks- True if links should be followed.- See Also:
DirectoryWalker()
-
SmartLinksDirectoryWalker
protected SmartLinksDirectoryWalker(boolean followLinks, FileFilter filter, int depthLimit)Constructor mirroring superclass constructor.- Parameters:
followLinks- True if links should be followed.filter- The filter to apply. It may be null, meaning visit all files.depthLimit- Controls to what depth the hierarchy is navigated. Less than 0 means unlimited.- See Also:
DirectoryWalker(FileFilter,int)
-
SmartLinksDirectoryWalker
protected SmartLinksDirectoryWalker(boolean followLinks, org.apache.commons.io.filefilter.IOFileFilter directoryFilter, org.apache.commons.io.filefilter.IOFileFilter fileFilter, int depthLimit)Constructor mirroring superclass constructor.- Parameters:
followLinks- True if links should be followed.directoryFilter- The filter to apply to directories. It may be null, meaning visit all directories.fileFilter- The filter to apply to files. It may be null, meaning visit all directories.depthLimit- Controls to what depth the hierarchy is navigated. Less than 0 means unlimited.- See Also:
DirectoryWalker(IOFileFilter,IOFileFilter,int)
-
-
Method Detail
-
handleDirectory
protected boolean handleDirectory(File directory, int depth, Collection<String> results) throws IOException
Returns false if the given directory is a symbolic link to a directory, and links are not to be followed, thereby blocking following the link during traversal. In this case, it also invokesDirectoryWalker.handleFile(File,int,Collection)on the link.- Overrides:
handleDirectoryin classorg.apache.commons.io.DirectoryWalker<String>- Throws:
IOException- See Also:
DirectoryWalker.handleDirectory(File,int,Collection)
-
getFollowLinks
public boolean getFollowLinks()
Returns true if symbolic links to directories should be followed during traversal.- Returns:
- True if so.
-
apply
public void apply(File root, Collection<String> results) throws IOException
Traverses the file tree rooted at the given root. The root may be nonexistent (no-op) or a plain file (which becomes the only file visited).- Parameters:
root- The root.results- An object passed intact intoDirectoryWalkercallbacks.- Throws:
IOException- Thrown if an I/O error occurs.
-
apply
public void apply(File root) throws IOException
Traverses the file tree rooted at the given root. The root may be nonexistent (no-op) or a plain file (which becomes the only file visited). Theresultsargument in allDirectoryWalkercallbacks will be null.- Parameters:
root- The root.- Throws:
IOException- Thrown if an I/O error occurs.
-
apply
public void apply(String name, Collection<String> results) throws IOException
Traverses the file tree rooted at the file with the given name. The root may be nonexistent (no-op) or a plain file (which becomes the only file visited).- Parameters:
name- The file name.results- An object passed intact intoDirectoryWalkercallbacks.- Throws:
IOException- Thrown if an I/O error occurs.
-
apply
public void apply(String name) throws IOException
Traverses the file tree rooted at the file with the given name. The root may be nonexistent (no-op) or a plain file (which becomes the only file visited). Theresultsargument in allDirectoryWalkercallbacks will be null.- Parameters:
name- The file name.- Throws:
IOException- Thrown if an I/O error occurs.
-
-