Class Scanner
- java.lang.Object
-
- org.glassfish.pfl.basic.tools.file.Scanner
-
public class Scanner extends java.lang.ObjectRecursively scan directories to process files.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceScanner.ActionAction interface passed to scan method to act on files.
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<java.lang.String>patternsToSkipprivate java.util.List<java.io.File>rootsprivate intverbose
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddDirectoryToSkip(java.lang.String pattern)Add a pattern that defines a directory to skip.private booleandoScan(java.io.File file, Scanner.Action action)private booleanmatch(java.lang.String pattern, java.lang.String fname)booleanscan(Scanner.Action action)Scan all files reachable from roots.private booleanskipDirectory(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)
-
-