Class PerDoclet

public class PerDoclet extends com.sun.javadoc.Doclet implements java.lang.Runnable
A doclet that generates XHTML output with UML class diagrams.


- root : com.sun.javadoc.RootDoc
- directory : java.lang.String
- umlpage : boolean
- nouml : boolean
+ APPNAME : java.lang.String
+ VERSION : java.lang.String
+ COPYRIGHT : java.lang.String
+ WEBSITE : java.lang.String
+ «constructor» PerDoclet(root:com.sun.javadoc.RootDoc)
+ optionLength(option:java.lang.String) : int
+ start(root:com.sun.javadoc.RootDoc) : boolean
+ run()
- writeClass(clazz:com.sun.javadoc.ClassDoc,
- writePackage(pack:com.sun.javadoc.PackageDoc,
- writeClassesList(classes:com.sun.javadoc.ClassDoc[], title:java.lang.String,
- writeField(field:com.sun.javadoc.FieldDoc,
- writeConstructor(con:com.sun.javadoc.ConstructorDoc,
- writeMethod(meth:com.sun.javadoc.MethodDoc,
- writeExecutableMemberComment(emd:com.sun.javadoc.ExecutableMemberDoc,
- writeClassUML(clazz:com.sun.javadoc.ClassDoc,
- writeUMLVisability(m:com.sun.javadoc.MemberDoc,
- writeOperationUML(emd:com.sun.javadoc.ExecutableMemberDoc,
- writeAttributeUML(field:com.sun.javadoc.FieldDoc,
- writeParametersCode(a:com.sun.javadoc.Parameter[],, fileDeepness:int)
- writeParameterCode(p:com.sun.javadoc.Parameter,, fileDeepness:int)
- writeThrowsCode(exceptions:com.sun.javadoc.ClassDoc[],, fileDeepness:int)
- writeTypeName(t:com.sun.javadoc.Type,, fileDeepness:int)
- writeClassName(cl:com.sun.javadoc.ClassDoc,, fileDeepness:int)
- writeUMLStereotype(name:java.lang.String,
- fileFor(clazz:com.sun.javadoc.ClassDoc) :
- fileFor(p:com.sun.javadoc.PackageDoc) :
- packageFileFor(name:java.lang.String) :
- directoryDeepness(clazz:com.sun.javadoc.ClassDoc) : int
- directoryDeepness(p:com.sun.javadoc.PackageDoc) : int
- toId(emd:com.sun.javadoc.ExecutableMemberDoc) : java.lang.String
- startFile(, title:java.lang.String, fileDeepness:int) :
- finishFile(
- writeStylesheet(


private com.sun.javadoc.RootDoc root
Root node.
private java.lang.String directory
The name of the document root directory. This is set by the "-d" option. Default is "doc".
private boolean umlpage
Flag for if only a UML page should be generated (-umlpage option). This is false by default.
private boolean nouml
Flag for if no UML should be generated (-nouml option). This is false by default, meaning UML should be included.
public static final java.lang.String APPNAME
The name of this doclet.
public static final java.lang.String VERSION
The version of this software.
public static final java.lang.String WEBSITE
Website URL.


public PerDoclet(com.sun.javadoc.RootDoc root)
Constructs instance and prepares it for documentation generation from specified source. Parameter root: the root node of the source information.


public static int optionLength(java.lang.String option)
Returns word length of available options. If option is "-help" is specified, available options are printed to standard console output. Returns: 1 on "-umlpage" or "-nouml", 2 on "-d" or 0 on unknown option.
public static boolean start(com.sun.javadoc.RootDoc root)
Starts the generation of the documentation.
public synchronized void run()
Documentation generation thread. This method is triggered from method start(RootDoc). Specified by interface java.lang.Runnable.
private void writeTree()
Writes all documentation according RootDoc.
private void writeUMLPage()
Writes one page with UML diagrams for all classes. File will get the name "uml.html" and be placed in the documentation root directory.
private void writeClass(com.sun.javadoc.ClassDoc clazz, pw)
Writes the full documentation for a class.
private void writePackage(com.sun.javadoc.PackageDoc pack, pw)
Writes contents for package page. A list of classes will be written, divided into Interfaces, Classes, Exceptions and Erros.
private void writeClassesList(com.sun.javadoc.ClassDoc[] classes, java.lang.String title, pw)
Writes a list of classes for a package page. Parameter classes: the classes to include in the list. Parameter title: the category name of the specified classes.
private void writeField(com.sun.javadoc.FieldDoc field, pw)
Writes documentation for a field.
private void writeConstructor(com.sun.javadoc.ConstructorDoc con, pw)
Writes documentation for a constructor.
private void writeMethod(com.sun.javadoc.MethodDoc meth, pw)
Writes documentation for a method.
private void writeExecutableMemberComment(com.sun.javadoc.ExecutableMemberDoc emd, pw)
Writes documentation for a "executable member". Parameter emd: the "executable member"; a constructor or a method.
private void writeClassUML(com.sun.javadoc.ClassDoc clazz, pw)
Writes a UML class diagram. Parameter clazz: the class to write diagram of.
private void writeUMLVisability(com.sun.javadoc.MemberDoc m, pw)
Writes UML visability for a field, constructor or method. Parameter m: field, constructor or method to write visability for.
private void writeOperationUML(com.sun.javadoc.ExecutableMemberDoc emd, pw)
Writes a constructor or method as an UML operation. Parameter the: constructor or method to write as an UML operation.
private void writeAttributeUML(com.sun.javadoc.FieldDoc field, pw)
Writes field as UML attribute.
private void writeParametersCode(com.sun.javadoc.Parameter[] a, pw, int fileDeepness)
Writes a line-up of parameters. Parameter a: the parameters of the line-up.
private void writeParameterCode(com.sun.javadoc.Parameter p, pw, int fileDeepness)
Writes an item in a line-up of parameters.
private void writeThrowsCode(com.sun.javadoc.ClassDoc[] exceptions, pw, int fileDeepness)
Write "throws" suffix for method or constructor signature. Parameter exceptions: the classes for the exceptions that can be thrown by the method or constructor.
private void writeTypeName(com.sun.javadoc.Type t, pw, int fileDeepness)
Writes "type" name. Type is a class or a primitive type followed by dimension. A class name will be linked if there is a documentation page for it.
private void writeClassName(com.sun.javadoc.ClassDoc cl, pw, int fileDeepness)
Writes the name of a class, linking it to the documentation of that class, if any.
private void writeUMLStereotype(java.lang.String name, pw)
Writes UML stereotype. Parameter name: the stereotype name.
private fileFor(com.sun.javadoc.ClassDoc clazz)
Gets the documentation file path for a class. Parameter clazz: the class to get the file path for. Returns: a path where documentation for the class is or will be.
private fileFor(com.sun.javadoc.PackageDoc p)
Gets the path for a package page. Parameter p: the package to get path for. Returns: a File.
private packageFileFor(java.lang.String name)
Gets the path for package name. Parameter name: the full name of the package. Returns: an "index.html" File.
private static int directoryDeepness(com.sun.javadoc.ClassDoc clazz)
Returns how deep in the directory structure, relative to documentation root directory, a documentation file for a class should be. Parameter clazz: the class to get the "deepness" for. Returns: 0 if class not in a package, otherwise a value bigger or equal to 1.
private static int directoryDeepness(com.sun.javadoc.PackageDoc p)
Returns how deep in the directory structure a package page should be.
private static java.lang.String toId(com.sun.javadoc.ExecutableMemberDoc emd)
Generates a HTML id value for an "executable member".
private startFile( f, java.lang.String title, int fileDeepness) throws
Begins an XHTML output file. Parameter f: the file to begin. Parameter title: the title of the document.
private void finishFile( pw) throws
Writes the last lines of XHTML output file.
private void writeStylesheet()
Writes stylesheet file, if not already existing. The name of the stylesheet file is always "perdoclet-style.css" and is located in the documentation root directory.
private void writeStylesheet( os) throws
Writes stylesheet to specified stream. Parameter os: the stream to write the stylesheet file contents to.