import com.sun.javadoc.PackageDoc; //导入方法依赖的package包/类
/**
* Try to determine the source directory for the given package by
* looking at the path specified by -sourcepath, or the current
* directory if -sourcepath hasn't been specified.
*
* @throws IOException if the source directory couldn't be
* located.
*
* @return List of File
*/
protected List getPackageSourceDirs(PackageDoc packageDoc)
throws IOException
{
if (null == sourcePaths) {
for (int i=0; i
if ("-sourcepath".equals(rootDoc.options()[i][0])
|| "-s".equals(rootDoc.options()[i][0])) {
sourcePaths = new LinkedHashSet();
String sourcepathString = rootDoc.options()[i][1];
StringTokenizer st = new StringTokenizer(sourcepathString, File.pathSeparator);
while (st.hasMoreTokens()) {
sourcePaths.add(new File(st.nextToken()));
}
}
}
if (null == sourcePaths) {
sourcePaths = new LinkedHashSet();
sourcePaths.add(new File(System.getProperty("user.dir")));
}
}
String packageSubDir = packageDoc.name().replace('.', File.separatorChar);
Iterator it = sourcePaths.iterator();
List result = new LinkedList();
while (it.hasNext()) {
File pathComponent = (File)it.next();
File packageDir = new File(pathComponent, packageSubDir);
if (packageDir.exists()) {
result.add(packageDir);
}
}
if (result.isEmpty()) {
throw new IOException("Couldn't locate source directory for package " + packageDoc.name());
}
else {
return result;
}
}