Package gov.nasa.pds.tools.validate.rule
Class AbstractFileSubtreeWalker<T>
- java.lang.Object
-
- gov.nasa.pds.tools.validate.rule.AbstractFileSubtreeWalker<T>
-
- Type Parameters:
T
- the type used by the concrete subclass to keep track of state
public abstract class AbstractFileSubtreeWalker<T> extends Object
Implements a class that walks a file system subtree and performs an operation on each file or directory found.
-
-
Constructor Summary
Constructors Constructor Description AbstractFileSubtreeWalker()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract T
handleDirectory(URL dir, T state)
Handles encountering a directory.protected abstract void
handleFile(URL f, T state)
Handles encountering a file.void
walkSubtree(URL url, T state)
Walks a subtree starting from a specified file or directory.
-
-
-
Method Detail
-
walkSubtree
public void walkSubtree(URL url, T state)
Walks a subtree starting from a specified file or directory.- Parameters:
f
- a file or directorystate
- the state managed by the caller
-
handleDirectory
protected abstract T handleDirectory(URL dir, T state) throws Exception
Handles encountering a directory. Subclasses should implement the processing for directories in this method.- Parameters:
dir
- the directory encounteredstate
- the current walking state- Returns:
- the new state for walking children of this directory
- Throws:
Exception
- if there is an error processing the directory
-
handleFile
protected abstract void handleFile(URL f, T state) throws Exception
Handles encountering a file. Subclasses should implement the processing for files in this method.- Parameters:
f
- the file encounteredstate
- the current walking state- Throws:
Exception
- if there is an error processing the file
-
-