org.hackystat.sensor.ant.util
Class JavaClass2FilePathMapper

java.lang.Object
  extended by org.hackystat.sensor.ant.util.JavaClass2FilePathMapper

public class JavaClass2FilePathMapper
extends java.lang.Object

Provides a facility for mapping fully qualified Java class names to their corresponding fully qualified Java source files. Also allows retrieval of the source directory corresponding to a package name.

Author:
(Cedric) Qin Zhang

Constructor Summary
JavaClass2FilePathMapper(java.util.Collection<java.io.File> fullyQualifiedFileNames)
          This constructor accepts a list of file names, and processes this list to build two parallel arrays.
JavaClass2FilePathMapper(java.util.Set<java.lang.String> fullyQualifiedFileNames)
          This constructor accepts a list of file names, and processes this list to build two parallel arrays.
 
Method Summary
 java.lang.String getFilePath(java.lang.String fullyQualifiedClassName)
          Returns a string containing the java file name corresponding to the passed class name.
 java.lang.String getPackagePath(java.lang.String packageName)
          Returns the path associated with a package name.
 java.lang.String toString()
          Returns the canonical file names array.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

JavaClass2FilePathMapper

public JavaClass2FilePathMapper(java.util.Collection<java.io.File> fullyQualifiedFileNames)
This constructor accepts a list of file names, and processes this list to build two parallel arrays. The first array contains all of the .java file names found in the passed list, and the second contains these same file names with the path separator replaced by a canonical separator.

Parameters:
fullyQualifiedFileNames - A collection of string representing fully qualified file paths or directory path for java files.

JavaClass2FilePathMapper

public JavaClass2FilePathMapper(java.util.Set<java.lang.String> fullyQualifiedFileNames)
This constructor accepts a list of file names, and processes this list to build two parallel arrays. The first array contains all of the .java file names found in the passed list, and the second contains these same file names with the path separator replaced by a canonical separator.

Parameters:
fullyQualifiedFileNames - A collection of string representing fully qualified file paths or directory path for java files.
Method Detail

getFilePath

public java.lang.String getFilePath(java.lang.String fullyQualifiedClassName)
Returns a string containing the java file name corresponding to the passed class name.

Parameters:
fullyQualifiedClassName - The java class name.
Returns:
The java file name, or null if there is no mapping information.

toString

public java.lang.String toString()
Returns the canonical file names array.

Overrides:
toString in class java.lang.Object
Returns:
The array of canonical file names.

getPackagePath

public java.lang.String getPackagePath(java.lang.String packageName)
Returns the path associated with a package name. If a path is not found, an empty string is returned.

Parameters:
packageName - the name of the package.
Returns:
the path associated with the package name. An empty string is returned if a path is not found.