net.sf.javadocbuilder
Class Builder

java.lang.Object
  |
  +--net.sf.javadocbuilder.Builder
All Implemented Interfaces:
Constants

public final class Builder
extends java.lang.Object
implements Constants

Simple builder to generate content from @javadocs tags in the xdoclet style.

Author:
Miguel Griffa

Field Summary
private  com.thoughtworks.qdox.JavaDocBuilder builder
          QDox parser
private  net.sf.javadocbuilder.BuilderConfiguration cfg
          Configuration data for the builder
private  IResourceDelta delta
          resouce delta when building incrementally
private  ILog elog
          eclipse friendly logger
private  int filesWritten
          Counter of written files in multiple output mode.
private static net.sf.javadocbuilder.JavaHelper javaHelper
           
private static java.util.logging.Logger log
          development logging
private  IProgressMonitor monitor
          progress monitor for user feedback
private  IProject project
          the project we are working with
private  com.thoughtworks.qdox.model.JavaSource[] source
          qdox parsing results
 
Fields inherited from interface net.sf.javadocbuilder.Constants
ARG_CLASSNAME_FILTER_ENABLED, ARG_CLASSNAME_FILTER_PATTERN, ARG_CUSTOM_TEMPLATE_NAME, ARG_OUT_DIR, ARG_OUT_NAME_PATTERN, ARG_SINGLE_FILE, ARG_SOURCE_DIRECTORIES, ARG_TAG_FILTER_ENABLED, ARG_TAG_FILTER_NAME, ARG_TEMPLATE_NAME, CONFIGURATION_FILENAME
 
Constructor Summary
Builder(IProject prj, net.sf.javadocbuilder.BuilderConfiguration conf, IResourceDelta d)
           
 
Method Summary
protected  IProject[] build(int kind, IProgressMonitor monitor)
           
private  void buildFile(com.thoughtworks.qdox.model.JavaSource javaSrc)
          Writes the content of a single file for multiple output mode.
private  void buildFull()
           
private  void buildIncremental(IResourceDelta delta)
           
private  void createParentsIfNeeded(IContainer cont)
          Creates all neccesary parents for the given file
private  void doMultipleOutput()
          perform the build when multiple output files are generated.
private  void doSingleOutput()
           
private  com.thoughtworks.qdox.model.JavaSource getJavaSourceFor(IResource resource)
          Gets the JavaSource for a given IResource or null if not found.
private  java.lang.String getOutputFilenameFor(com.thoughtworks.qdox.model.JavaSource src)
          gets the output filename for the given java source.
private  IFile getOutputIFile(java.lang.String outName)
          Gets the IFile for the filename
private  java.io.InputStream getTemplateInputStream()
          gets an inputString with the configured template name.
private  boolean hasClassMatching(com.thoughtworks.qdox.model.JavaSource javaSrc)
          Tells if there is at lease one class in JavaSource matching the pattern
private  boolean hasClassWithTag(com.thoughtworks.qdox.model.JavaSource src, java.lang.String tagName)
          Tells if the given Javasource has at least class with the specified tag.
private  com.thoughtworks.qdox.model.JavaSource[] parseJavaFiles()
          Parse #sourceDirectories with qdox and return a JavaSource[] structure.
private  boolean passesFilters(com.thoughtworks.qdox.model.JavaSource javaSrc)
          Tests the JavaSource againsts active filters.
private  java.lang.String runVelocity(com.thoughtworks.qdox.model.JavaSource src, com.thoughtworks.qdox.model.JavaClass clazz)
           
private  java.lang.String substituteVariables(com.thoughtworks.qdox.model.JavaSource src, java.lang.String string)
          Perform variable substitutions on the string for the given java source.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

project

private IProject project
the project we are working with


monitor

private IProgressMonitor monitor
progress monitor for user feedback


source

private com.thoughtworks.qdox.model.JavaSource[] source
qdox parsing results


elog

private ILog elog
eclipse friendly logger


log

private static java.util.logging.Logger log
development logging


builder

private com.thoughtworks.qdox.JavaDocBuilder builder
QDox parser


cfg

private net.sf.javadocbuilder.BuilderConfiguration cfg
Configuration data for the builder


delta

private IResourceDelta delta
resouce delta when building incrementally


filesWritten

private int filesWritten
Counter of written files in multiple output mode.


javaHelper

private static final net.sf.javadocbuilder.JavaHelper javaHelper
Constructor Detail

Builder

public Builder(IProject prj,
               net.sf.javadocbuilder.BuilderConfiguration conf,
               IResourceDelta d)
Method Detail

build

protected IProject[] build(int kind,
                           IProgressMonitor monitor)
                    throws java.lang.Exception
java.lang.Exception

buildIncremental

private void buildIncremental(IResourceDelta delta)
                       throws java.lang.Exception
java.lang.Exception

getJavaSourceFor

private com.thoughtworks.qdox.model.JavaSource getJavaSourceFor(IResource resource)
Gets the JavaSource for a given IResource or null if not found.

Parameters:
resource -
Returns:

buildFull

private void buildFull()
                throws java.lang.Exception
java.lang.Exception

doSingleOutput

private void doSingleOutput()
                     throws java.lang.Exception
java.lang.Exception

createParentsIfNeeded

private void createParentsIfNeeded(IContainer cont)
                            throws CoreException
Creates all neccesary parents for the given file

CoreException

getOutputIFile

private IFile getOutputIFile(java.lang.String outName)
                      throws CoreException
Gets the IFile for the filename

Parameters:
outName -
Returns:
CoreException

doMultipleOutput

private void doMultipleOutput()
                       throws java.lang.Exception
perform the build when multiple output files are generated.

Throws:
CoreException
java.lang.Exception

hasClassWithTag

private boolean hasClassWithTag(com.thoughtworks.qdox.model.JavaSource src,
                                java.lang.String tagName)
Tells if the given Javasource has at least class with the specified tag.

Parameters:
tagName -
Returns:

parseJavaFiles

private com.thoughtworks.qdox.model.JavaSource[] parseJavaFiles()
Parse #sourceDirectories with qdox and return a JavaSource[] structure.

Returns:

buildFile

private void buildFile(com.thoughtworks.qdox.model.JavaSource javaSrc)
                throws java.lang.Exception
Writes the content of a single file for multiple output mode.

Parameters:
javaSrc -
Throws:
java.lang.Exception - if an unexpected error occurs

passesFilters

private boolean passesFilters(com.thoughtworks.qdox.model.JavaSource javaSrc)
Tests the JavaSource againsts active filters.

Parameters:
javaSrc -
Returns:

hasClassMatching

private boolean hasClassMatching(com.thoughtworks.qdox.model.JavaSource javaSrc)
Tells if there is at lease one class in JavaSource matching the pattern

Parameters:
javaSrc -
Returns:

runVelocity

private java.lang.String runVelocity(com.thoughtworks.qdox.model.JavaSource src,
                                     com.thoughtworks.qdox.model.JavaClass clazz)
                              throws java.lang.Exception
Returns:
java.lang.Exception

getTemplateInputStream

private java.io.InputStream getTemplateInputStream()
                                            throws java.io.IOException,
                                                   CoreException
gets an inputString with the configured template name. This method will search the templateName variable, which must be valid inside the templates directory in the plugin dir, or the customTempalteName which must point to a velocity template inside the current workpsace

Returns:
java.io.IOException
CoreException

getOutputFilenameFor

private java.lang.String getOutputFilenameFor(com.thoughtworks.qdox.model.JavaSource src)
gets the output filename for the given java source. This method proceesses #outPattern by performing the following subsitutions and returning the resulting string:
  1. {package.name} by the package as it appears on the package declaration
  2. {package.dir} by the directory of the package
  3. {class.name} by the name of the current java class
NOTEThe output directory must include the project name this is for not forcing to work inside the same project, but having available the full workspace.

Parameters:
src - java source we are requesting an output name for
Returns:
a Stringwith the configured filename

substituteVariables

private java.lang.String substituteVariables(com.thoughtworks.qdox.model.JavaSource src,
                                             java.lang.String string)
Perform variable substitutions on the string for the given java source.

Parameters:
src -
Returns: