JavaDocBuilder
Date: 2017-03-29

com.thoughtworks.qdox

## Class JavaDocBuilder

- java.lang.Object
- - com.thoughtworks.qdox.JavaDocBuilder

- All Implemented Interfaces:
    java.io.Serializable

      public class JavaDocBuilder
      extends java.lang.Object
      implements java.io.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();

  See Also:
    Serialized Form

- - ### Nested Class Summary

    Nested Classes
    Modifier and Type | Class and Description
    --- | ---
    `static class` | `JavaDocBuilder.DefaultErrorHandler`
    `static interface` | `JavaDocBuilder.ErrorHandler`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `JavaDocBuilder()`
    `JavaDocBuilder(ClassLibrary classLibrary)`
    `JavaDocBuilder(DocletTagFactory docletTagFactory)`
    `JavaDocBuilder(DocletTagFactory docletTagFactory, ClassLibrary classLibrary)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `JavaSource` | `addSource(java.io.File file)`
    `JavaSource` | `addSource(java.io.Reader reader)`
    `JavaSource` | `addSource(java.io.Reader reader, java.lang.String sourceInfo)`
    `JavaSource` | `addSource(java.net.URL url)`
    `void` | `addSourceTree(java.io.File file)` Add all files in a directory (and subdirs, recursively).
    `void` | `addSourceTree(java.io.File file, FileVisitor errorHandler)` Add all files in a directory (and subdirs, recursively).
    `protected JavaClass` | `createBinaryClass(java.lang.String name)`
    `protected JavaClass` | `createSourceClass(java.lang.String name)`
    `protected JavaClass` | `createUnknownClass(java.lang.String name)`
    `JavaClass` | `getClassByName(java.lang.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` | `getPackageByName(java.lang.String name)`
    `JavaPackage[]` | `getPackages()` Returns all the packages found in all the sources.
    `JavaSource[]` | `getSources()`
    `static JavaDocBuilder` | `load(java.io.File file)` Note that after loading JavaDocBuilder classloaders need to be re-added.
    `void` | `save(java.io.File file)`
    `java.util.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(java.lang.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(java.lang.String name)

    - #### createSourceClass

          protected JavaClass createSourceClass(java.lang.String name)

    - #### createUnknownClass

          protected JavaClass createUnknownClass(java.lang.String name)

    - #### createBinaryClass

          protected JavaClass createBinaryClass(java.lang.String name)

    - #### addSource

          public JavaSource addSource(java.io.Reader reader)

    - #### addSource

          public JavaSource addSource(java.io.Reader reader,
                             java.lang.String sourceInfo)

    - #### addSource

          public JavaSource addSource(java.io.File file)
                               throws java.io.IOException,
                                      java.io.FileNotFoundException

      Throws:
        `java.io.IOException`
        `java.io.FileNotFoundException`

    - #### addSource

          public JavaSource addSource(java.net.URL url)
                               throws java.io.IOException,
                                      java.io.FileNotFoundException

      Throws:
        `java.io.IOException`
        `java.io.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(java.io.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(java.io.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 java.util.List search(Searcher searcher)

    - #### getClassLibrary

          public ClassLibrary getClassLibrary()

    - #### save

          public void save(java.io.File file)
                    throws java.io.IOException

      Throws:
        `java.io.IOException`

    - #### load

          public static JavaDocBuilder load(java.io.File file)
                                     throws java.io.IOException

      Note that after loading JavaDocBuilder classloaders need to be re-added.
      Throws:
        `java.io.IOException`

    - #### setEncoding

          public void setEncoding(java.lang.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.

    - #### getPackageByName

          public JavaPackage getPackageByName(java.lang.String name)