net.sourceforge.cobertura.util
Class FileFinder
java.lang.Object
net.sourceforge.cobertura.util.FileFinder
Maps source file names to existing files. After adding description
of places files can be found in, it can be used to localize
the files.
FileFinder supports two types of source files locations:
- source root directory, defines the directory under
which source files are located,
- pair (base directory, file path relative to base directory).
The difference between these two is that in case of the first you add all
source files under the specified root directory, and in the second you add
exactly one file. In both cases file to be found has to be located under
subdirectory that maps to package definition provided with the source file name.
void | addSourceDirectory(String directory) - Adds directory that is a root of sources.
|
void | addSourceFile(String baseDir, String file) - Adds file by specifying root directory and relative path to the
file in it.
|
private String | getCorrectedPath(String path)
|
File | getFileForSource(String fileName) - Maps source file name to existing file.
|
List | getSourceDirectoryList() - Returns a list with string for all source directories.
|
String | toString() - Returns string representation of FileFinder.
|
LOGGER
private static Logger LOGGER
addSourceDirectory
public void addSourceDirectory(String directory)
Adds directory that is a root of sources. A source file
that is under this directory will be found if relative
path to the file from root matches package name.
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 files
addSourceFile
public void addSourceFile(String baseDir,
String file)
Adds file by specifying root directory and relative path to the
file in it. Adds exactly one file, relative path should match
package that the source file is in, otherwise it will be not
found later.
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
getFileForSource
public File getFileForSource(String fileName)
throws IOException
fileName
- source file to be mapped
- existing file that maps to passed sourceFile
getSourceDirectoryList
public List getSourceDirectoryList()
Returns a list with string for all source directories.
Example: [C:/MyProject/src/main,C:/MyProject/src/test]
- list with Strings for all source roots, or empty list if no source roots were specified
toString
public String toString()
Returns string representation of FileFinder.