com.thoughtworks.qdox
Class JavaDocBuilder

java.lang.Object
  extended by com.thoughtworks.qdox.JavaDocBuilder
All Implemented Interfaces:
Serializable

public class JavaDocBuilder
extends Object
implements Serializable

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();

 

Author:
Joe Walnes, Aslak Hellesøy, Robert Scholte
See Also:
Serialized Form

Nested Class Summary
static class JavaDocBuilder.DefaultErrorHandler
           
static interface JavaDocBuilder.ErrorHandler
           
 
Constructor Summary
JavaDocBuilder()
           
JavaDocBuilder(ClassLibrary classLibrary)
           
JavaDocBuilder(DocletTagFactory docletTagFactory)
           
JavaDocBuilder(DocletTagFactory docletTagFactory, ClassLibrary classLibrary)
           
 
Method Summary
 JavaSource addSource(File file)
           
 JavaSource addSource(Reader reader)
           
 JavaSource addSource(Reader reader, String sourceInfo)
           
 JavaSource addSource(URL url)
           
 void addSourceTree(File file)
          Add all files in a directory (and subdirs, recursively).
 void addSourceTree(File file, FileVisitor errorHandler)
          Add all files in a directory (and subdirs, recursively).
protected  JavaClass createBinaryClass(String name)
           
protected  JavaClass createUnknownClass(String name)
           
 JavaClass getClassByName(String name)
           
 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).
 ClassLibrary getClassLibrary()
           
 JavaPackage[] getPackages()
          Returns all the packages found in all the sources.
 JavaSource[] getSources()
           
static JavaDocBuilder load(File file)
          Note that after loading JavaDocBuilder classloaders need to be re-added.
 void save(File file)
           
 List search(Searcher searcher)
           
 void setDebugLexer(boolean debugLexer)
          Forces QDox to dump tokens returned from lexer to System.err.
 void setDebugParser(boolean debugParser)
          Forces QDox to dump parser states to System.out.
 void setEncoding(String encoding)
           
 void setErrorHandler(JavaDocBuilder.ErrorHandler errorHandler)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JavaDocBuilder

public JavaDocBuilder()

JavaDocBuilder

public JavaDocBuilder(DocletTagFactory docletTagFactory)

JavaDocBuilder

public JavaDocBuilder(ClassLibrary classLibrary)

JavaDocBuilder

public JavaDocBuilder(DocletTagFactory docletTagFactory,
                      ClassLibrary classLibrary)
Method Detail

getClassByName

public JavaClass getClassByName(String name)

createUnknownClass

protected JavaClass createUnknownClass(String name)

createBinaryClass

protected JavaClass createBinaryClass(String name)

addSource

public JavaSource addSource(Reader reader)

addSource

public JavaSource addSource(Reader reader,
                            String sourceInfo)

addSource

public JavaSource addSource(File file)
                     throws IOException,
                            FileNotFoundException
Throws:
IOException
FileNotFoundException

addSource

public JavaSource addSource(URL url)
                     throws IOException,
                            FileNotFoundException
Throws:
IOException
FileNotFoundException

setErrorHandler

public void setErrorHandler(JavaDocBuilder.ErrorHandler errorHandler)

getSources

public JavaSource[] getSources()

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).

Returns:
all the classes found in all the sources.
Since:
1.3

getPackages

public JavaPackage[] getPackages()
Returns all the packages found in all the sources.

Returns:
all the packages found in all the sources.
Since:
1.9

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.


search

public List search(Searcher searcher)

getClassLibrary

public ClassLibrary getClassLibrary()

save

public void save(File file)
          throws IOException
Throws:
IOException

load

public static JavaDocBuilder load(File file)
                           throws IOException
Note that after loading JavaDocBuilder classloaders need to be re-added.

Throws:
IOException

setEncoding

public void setEncoding(String encoding)

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.



Copyright © 2002-2011. All Rights Reserved.