QDox Usage

## Entry Point

`JavaDocBuilder` is the entry point to QDox. It is responsible for parsing source code, resolving imports and storing the data.

To create it, all you need to do is call the default constructor.

    JavaDocBuilder builder = new JavaDocBuilder();

## Reading Source Files

Java source code can then be added to the `JavaDocBuilder`. Source can either be read one file at a time (using a java.io.Reader) or an entire source tree can be added recursively.

    // 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"));

## Resolving Class Names

In order to resolve classes that have been imported using a wildcard (e.g. `import java.util.*;`), the `ClassLibrary` must be aware of other classes used in the project.

ClassLibrary has 4 ways to resolve classes:

- By looking at other sources that have been added.
- By searching through the supplied sourceFolders
- By looking in the current classpath (including the standard JRE classes).
- By looking at additional ClassLoaders specified at runtime.

All sources and sourcetrees added to the JavaDocBuilder will be parsed. This is often much more than required. To increase efficiency use the ClassLibrary to add sourcefolders. Consider these files as lazy parsed sources.

The current classpath is automaticly set by JavaDocBuilder. In most cases this shall be sufficient, however in some situations you may want resolve the full classes in external libraries.

To resolve classes from different ClassLoaders (e.g. 3rd party Jar files), the `addClassLoader()` method must be called on the ClassLibrary.

    // Get the ClassLibrary
    ClassLibrary lib = builder.getClassLibrary();

    // Add a sourcefolder;
    lib.addSourceFolder( new File( "src/main/java" ) );
    lib.addSourceFolder( new File( "target/generated-sources/foobar" ) );

    // Add a custom ClassLoader
    lib.addClassLoader( myCustomClassLoader );

    // Ant example : add the <classpath> element's contents
    lib.addClassLoader( new AntClassLoader( getProject(), classpath ) );

It is important that additional ClassLoaders are added before any source files are parsed.

## Navigating The Model

Now the files have been parsed, move on to navigating the model.