com.thoughtworks.qdox
Class JavaDocBuilder
java.lang.Object
com.thoughtworks.qdox.JavaDocBuilder
- Serializable, JavaClassCache
public class JavaDocBuilder
extends java.lang.Object
Simple facade to QDox allowing a source tree to be parsed and the resulting object model navigated.
Example
// -- Create JavaDocBuilder
JavaDocBuilder builder = new JavaDocBuilder();
// -- Add some files
// Reading a single source file.
builder.addSource(new FileReader("MyFile.java"));
// Reading from another kind of input stream.
builder.addSource(new StringReader("package test; public class Hello {}"));
// Adding all .java files in a source tree (recursively).
builder.addSourceTree(new File("mysrcdir"));
// -- Retrieve source files
JavaSource[] source = builder.getSources();
JavaDocBuilder
public JavaDocBuilder()
addSource
public JavaSource addSource(File file)
throws IOException,
FileNotFoundException
addSource
public JavaSource addSource(Reader reader)
addSource
public JavaSource addSource(Reader reader,
String sourceInfo)
addSource
public JavaSource addSource(URL url)
throws IOException,
FileNotFoundException
addSourceTree
public void addSourceTree(File file)
Add all files in a directory (and subdirs, recursively).
If a file cannot be read, a RuntimeException shall be thrown.
addSourceTree
public void addSourceTree(File file,
FileVisitor errorHandler)
Add all files in a directory (and subdirs, recursively).
If a file cannot be read, errorHandler will be notified.
getClasses
public JavaClass[] getClasses()
Returns all the classes found in all the sources, including inner classes
and "extra" classes (multiple outer classes defined in the same source file).
- getClasses in interface JavaClassCache
- all the classes found in all the sources.
load
public static JavaDocBuilder load(File file)
throws IOException
Note that after loading JavaDocBuilder classloaders need to be re-added.
save
public void save(File file)
throws IOException
search
public List search(Searcher searcher)
setDebugLexer
public void setDebugLexer(boolean debugLexer)
Forces QDox to dump tokens returned from lexer to System.err.
setDebugParser
public void setDebugParser(boolean debugParser)
Forces QDox to dump parser states to System.out.
setEncoding
public void setEncoding(String encoding)