01: package net.sourceforge.jaxor.parser;
02:
03: import com.thoughtworks.qdox.JavaDocBuilder;
04: import com.thoughtworks.qdox.model.JavaClass;
05: import com.thoughtworks.qdox.model.JavaSource;
06: import net.sourceforge.jaxor.util.SystemException;
07: import org.apache.tools.ant.DirectoryScanner;
08: import org.apache.tools.ant.Project;
09: import org.apache.tools.ant.types.FileSet;
10:
11: import java.io.File;
12: import java.io.FileNotFoundException;
13: import java.io.FileReader;
14: import java.util.ArrayList;
15: import java.util.List;
16:
17: /*
18: * User: Mike
19: * Date: Jul 19, 2003
20: * Time: 2:46:32 PM
21: */
22:
23: public class ImplParser {
24:
25: private final List filesets = new ArrayList();
26:
27: public void addConfiguredFileset(FileSet fs) {
28: filesets.add(fs);
29: }
30:
31: public SourceMap findSource(Project project) {
32: JavaDocBuilder builder = new JavaDocBuilder();
33: SourceMap sources = new SourceMap();
34: for (int i = 0; i < filesets.size(); i++) {
35: FileSet fs = (FileSet) filesets.get(i);
36: DirectoryScanner ds = fs.getDirectoryScanner(project);
37: String[] srcFiles = ds.getIncludedFiles();
38: for (int j = 0; j < srcFiles.length; j++) {
39: String srcFile = srcFiles[j];
40: try {
41: File file = new File(ds.getBasedir(), srcFile);
42: JavaSource src = builder.addSource(new FileReader(
43: file));
44: JavaClass[] classes = src.getClasses();
45: for (int k = 0; k < classes.length; k++) {
46: JavaClass aClass = classes[k];
47: sources.put(aClass, file);
48: }
49: } catch (FileNotFoundException e) {
50: throw new SystemException(e);
51: }
52: }
53: }
54: return sources;
55: }
56: }
|