public class FileFinder extends java.lang.Object
FileFinder supports two types of source files locations:
Modifier and Type | Class and Description |
---|---|
private class |
FileFinder.JarZipFilter
A filter that accepts files that end in .jar or .zip
|
Modifier and Type | Field and Description |
---|---|
private static org.apache.log4j.Logger |
LOGGER |
private java.util.Set |
sourceDirectories |
private java.util.Map |
sourceFilesMap |
Constructor and Description |
---|
FileFinder() |
Modifier and Type | Method and Description |
---|---|
void |
addSourceDirectory(java.lang.String directory)
Adds directory that is a root of sources.
|
void |
addSourceFile(java.lang.String baseDir,
java.lang.String file)
Adds file by specifying root directory and relative path to the
file in it.
|
private java.lang.String |
getCorrectedPath(java.lang.String path) |
java.io.File |
getFileForSource(java.lang.String fileName)
Maps source file name to existing file.
|
Source |
getSource(java.lang.String fileName)
Maps source file name to existing file or source archive.
|
java.util.List |
getSourceDirectoryList()
Returns a list with string for all source directories.
|
private Source |
searchJarsForSource(java.lang.String fileName)
Gets a BufferedReader for a file within a jar.
|
java.lang.String |
toString()
Returns string representation of FileFinder.
|
private static org.apache.log4j.Logger LOGGER
private java.util.Set sourceDirectories
private java.util.Map sourceFilesMap
public FileFinder()
public void addSourceDirectory(java.lang.String directory)
Example:
fileFinder.addSourceDirectory( "C:/MyProject/src/main"); fileFinder.addSourceDirectory( "C:/MyProject/src/test");In path both / and \ can be used.
directory
- The root of source filesjava.lang.NullPointerException
- if directory
is null
public void addSourceFile(java.lang.String baseDir, java.lang.String file)
Example:
fileFinder.addSourceFile( "C:/MyProject/src/main", "com/app/MyClass.java"); fileFinder.addSourceFile( "C:/MyProject/src/test", "com/app/MyClassTest.java");In paths both / and \ can be used.
baseDir
- sources root directoryfile
- path to source file relative to baseDir
java.lang.NullPointerException
- if either baseDir
or file
is null
public java.io.File getFileForSource(java.lang.String fileName) throws java.io.IOException
addSourceDirectory(java.lang.String)
and later added with addSourceFile(java.lang.String, java.lang.String)
are checked.fileName
- source file to be mappedjava.io.IOException
- if cannot map source file to existing filejava.lang.NullPointerException
- if fileName is nullpublic Source getSource(java.lang.String fileName)
addSourceDirectory(java.lang.String)
and later added with addSourceFile(java.lang.String, java.lang.String)
are checked.fileName
- source file to be mappedjava.lang.NullPointerException
- if fileName is nullprivate Source searchJarsForSource(java.lang.String fileName)
fileName
- source file to get an input stream forpublic java.util.List getSourceDirectoryList()
[C:/MyProject/src/main,C:/MyProject/src/test]
private java.lang.String getCorrectedPath(java.lang.String path)
public java.lang.String toString()
toString
in class java.lang.Object