public class FileFinder extends java.lang.Object implements FileHandler
Modifier | Constructor and Description |
---|---|
protected |
FileFinder()
Initialize the new instance with default values.
|
Modifier and Type | Method and Description |
---|---|
protected java.io.File[] |
collectDirectories(java.lang.String dir,
java.lang.String pattern,
boolean recursive,
java.lang.Character digitWildcard) |
protected java.io.File[] |
collectFiles(java.lang.String pattern,
java.lang.Character digitWildcard) |
protected java.io.File[] |
collectFiles(java.lang.String dir,
java.lang.String pattern,
boolean recursive,
java.lang.Character digitWildcard) |
boolean |
directoryEnd(java.io.File dir)
This method is called for each directory, that a FileWalker finished to walk through.
|
boolean |
directoryStart(java.io.File dir,
int count)
This method is called for each directory, that a FileWalker starts to walk through.
|
static java.io.File[] |
findDirectories(java.lang.String startDir,
java.lang.String pattern)
Return all directories that match the given pattern(s) start searching in the
specified startDir.
|
static java.io.File[] |
findDirectories(java.lang.String startDir,
java.lang.String pattern,
boolean recursive)
Return all directories that match the given pattern(s) start searching in the
specified startDir.
|
static java.io.File[] |
findDirectories(java.lang.String startDir,
java.lang.String pattern,
boolean recursive,
char digitWildcard)
Return all directories that match the given pattern(s) start searching in the
specified startDir.
|
static java.io.File |
findFile(java.lang.String filename)
Tries to find the file with the given Name.
|
static java.io.File |
findFileOnClasspath(java.lang.String filename)
Tries to find the file with the given Name on the classpath.
|
static java.io.File |
findFileOnPath(java.lang.String filename,
java.lang.String path)
Tries to find the file with the given name in one location of the given
location path.
|
static java.io.File[] |
findFiles(java.lang.String searchPattern)
Return all files that match the given search pattern.
|
static java.io.File[] |
findFiles(java.lang.String searchPattern,
char digitWildcard)
Return all files that match the given search pattern.
|
static java.io.File[] |
findFiles(java.lang.String dir,
java.lang.String pattern)
Return all files that match the given pattern(s) start searching in the
specified dir.
|
static java.io.File[] |
findFiles(java.lang.String dir,
java.lang.String pattern,
boolean recursive)
Return all files that match the given pattern(s) start searching in the
specified dir.
|
static java.io.File[] |
findFiles(java.lang.String dir,
java.lang.String pattern,
boolean recursive,
char digitWildcard)
Return all files that match the given pattern(s) start searching in the
specified dir.
|
protected java.util.List<java.io.File> |
getCollectedFiles() |
protected java.io.File[] |
getCollectedFilesArray() |
boolean |
handleException(java.lang.Exception ex,
java.io.File file)
This method is called for whenever an exception occurs in walking through
the directories.
|
boolean |
handleFile(java.io.File file)
This method is called for each file, that a FileWalker instance finds.
|
static java.net.URL |
locateFile(java.lang.String filename)
Tries to find the file with the given Name.
|
static java.net.URL |
locateFileOnClasspath(java.lang.String filename)
Tries to find the file with the given Name on the classpath.
|
static java.net.URL |
locateFileOnPath(java.lang.String filename,
Classpath path)
Tries to find the file with the given name in one location of the given
location path.
|
static java.net.URL |
locateFileOnPath(java.lang.String filename,
java.lang.String path)
Tries to find the file with the given name in one location of the given
location path.
|
protected void |
setCollectedFiles(java.util.List<java.io.File> newValue) |
protected FileFinder()
public static java.net.URL locateFile(java.lang.String filename)
public static java.net.URL locateFileOnClasspath(java.lang.String filename)
filename
- The name of the file to look forpublic static java.io.File findFileOnClasspath(java.lang.String filename)
public static java.net.URL locateFileOnPath(java.lang.String filename, java.lang.String path)
filename
- The name of the file to look forpath
- The path to look up for the file (e.g. "xxx.jar:test/lib:root.jar")public static java.net.URL locateFileOnPath(java.lang.String filename, Classpath path)
filename
- The name of the file to look forpath
- The path to look up for the file (e.g. "xxx.jar:test/lib:root.jar")public static java.io.File findFileOnPath(java.lang.String filename, java.lang.String path)
public static java.io.File findFile(java.lang.String filename)
public static java.io.File[] findFiles(java.lang.String dir, java.lang.String pattern)
dir
- The directory to start searching (must not be null)pattern
- The pattern(s) the filenames must match (must not be null )java.lang.IllegalArgumentException
- If dir or pattern is nullpublic static java.io.File[] findFiles(java.lang.String dir, java.lang.String pattern, boolean recursive)
dir
- The directory to start searching (must not be null)pattern
- The pattern(s) the filenames must match (must not be null )recursive
- If false, only dir is searched, otherwise all sub directories as welljava.lang.IllegalArgumentException
- If dir or pattern is nullpublic static java.io.File[] findFiles(java.lang.String dir, java.lang.String pattern, boolean recursive, char digitWildcard)
dir
- The directory to start searching (must not be null)pattern
- The pattern(s) the filenames must match (must not be null )recursive
- If false, only dir is searched, otherwise all sub directories as welldigitWildcard
- The wildcard character for digit representation in the pattern(s)java.lang.IllegalArgumentException
- If dir or pattern is nullpublic static java.io.File[] findFiles(java.lang.String searchPattern)
searchPattern
- The pattern containing path and filename pattern the files must match (must not be null )java.lang.IllegalArgumentException
- If searchPattern is nullpublic static java.io.File[] findFiles(java.lang.String searchPattern, char digitWildcard)
searchPattern
- The pattern containing path and filename pattern the files must match (must not be null )digitWildcard
- The wildcard character for digit representation in the pattern(s)java.lang.IllegalArgumentException
- If searchPattern is nullpublic static java.io.File[] findDirectories(java.lang.String startDir, java.lang.String pattern, boolean recursive, char digitWildcard)
startDir
- The directory to start searching (must not be null)pattern
- The pattern(s) the directorynames must match (must not be null )recursive
- If false, only startDir is searched, otherwise all sub directories as welldigitWildcard
- The wildcard character for digit representation in the pattern(s)java.lang.IllegalArgumentException
- If dir or pattern is nullpublic static java.io.File[] findDirectories(java.lang.String startDir, java.lang.String pattern, boolean recursive)
startDir
- The directory to start searching (must not be null)pattern
- The pattern(s) the directorynames must match (must not be null )recursive
- If false, only startDir is searched, otherwise all sub directories as welljava.lang.IllegalArgumentException
- If dir or pattern is nullpublic static java.io.File[] findDirectories(java.lang.String startDir, java.lang.String pattern)
startDir
- The directory to start searching (must not be null)pattern
- The pattern(s) the directorynames must match (must not be null )java.lang.IllegalArgumentException
- If dir or pattern is nullpublic boolean handleFile(java.io.File file)
handleFile
in interface FileHandler
file
- The file, currently found by the FileWalker instancepublic boolean handleException(java.lang.Exception ex, java.io.File file)
handleException
in interface FileHandler
ex
- The exception to handlefile
- The file, currently found by the FileWalker instancepublic boolean directoryEnd(java.io.File dir)
directoryEnd
in interface FileHandler
dir
- The directory, the FileWalker has finished to walk throughpublic boolean directoryStart(java.io.File dir, int count)
directoryStart
in interface FileHandler
dir
- The directory, the FileWalker is starting to walk throughcount
- The number of files and directories the FileWalker found in the directoryprotected java.io.File[] collectDirectories(java.lang.String dir, java.lang.String pattern, boolean recursive, java.lang.Character digitWildcard)
protected java.io.File[] collectFiles(java.lang.String dir, java.lang.String pattern, boolean recursive, java.lang.Character digitWildcard)
protected java.io.File[] collectFiles(java.lang.String pattern, java.lang.Character digitWildcard)
protected java.io.File[] getCollectedFilesArray()
protected java.util.List<java.io.File> getCollectedFiles()
protected void setCollectedFiles(java.util.List<java.io.File> newValue)