Class Scanner
- java.lang.Object
-
- org.glassfish.pfl.basic.tools.file.Scanner
-
public class Scanner extends java.lang.Object
Recursively scan directories to process files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Scanner.Action
Action interface passed to scan method to act on files.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>
patternsToSkip
private java.util.List<java.io.File>
roots
private int
verbose
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addDirectoryToSkip(java.lang.String pattern)
Add a pattern that defines a directory to skip.private boolean
doScan(java.io.File file, Scanner.Action action)
private boolean
match(java.lang.String pattern, java.lang.String fname)
boolean
scan(Scanner.Action action)
Scan all files reachable from roots.private boolean
skipDirectory(java.io.File file)
-
-
-
Method Detail
-
addDirectoryToSkip
public void addDirectoryToSkip(java.lang.String pattern)
Add a pattern that defines a directory to skip. We only need really simple patterns: just a single name that must match a component of a directory name exactly.
-
scan
public boolean scan(Scanner.Action action) throws java.io.IOException
Scan all files reachable from roots. Does a depth-first search. Ignores all directories (and their contents) that match an entry in patternsToSkip. Passes each file (not directories) to the action. If action returns false, scan terminates. The result of the scan is the result of the last action call.- Throws:
java.io.IOException
-
doScan
private boolean doScan(java.io.File file, Scanner.Action action) throws java.io.IOException
- Throws:
java.io.IOException
-
skipDirectory
private boolean skipDirectory(java.io.File file)
-
match
private boolean match(java.lang.String pattern, java.lang.String fname)
-
-