Class PerDoclet

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

UML

PerDoclet
- 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, pw:java.io.PrintWriter)
- writePackage(pack:com.sun.javadoc.PackageDoc, pw:java.io.PrintWriter)
- writeClassesList(classes:com.sun.javadoc.ClassDoc[], title:java.lang.String, pw:java.io.PrintWriter)
- writeField(field:com.sun.javadoc.FieldDoc, pw:java.io.PrintWriter)
- writeConstructor(con:com.sun.javadoc.ConstructorDoc, pw:java.io.PrintWriter)
- writeMethod(meth:com.sun.javadoc.MethodDoc, pw:java.io.PrintWriter)
- writeExecutableMemberComment(emd:com.sun.javadoc.ExecutableMemberDoc, pw:java.io.PrintWriter)
- writeClassUML(clazz:com.sun.javadoc.ClassDoc, pw:java.io.PrintWriter)
- writeUMLVisability(m:com.sun.javadoc.MemberDoc, pw:java.io.PrintWriter)
- writeOperationUML(emd:com.sun.javadoc.ExecutableMemberDoc, pw:java.io.PrintWriter)
- writeAttributeUML(field:com.sun.javadoc.FieldDoc, pw:java.io.PrintWriter)
- writeParametersCode(a:com.sun.javadoc.Parameter[], pw:java.io.PrintWriter, fileDeepness:int)
- writeParameterCode(p:com.sun.javadoc.Parameter, pw:java.io.PrintWriter, fileDeepness:int)
- writeThrowsCode(exceptions:com.sun.javadoc.ClassDoc[], pw:java.io.PrintWriter, fileDeepness:int)
- writeTypeName(t:com.sun.javadoc.Type, pw:java.io.PrintWriter, fileDeepness:int)
- writeClassName(cl:com.sun.javadoc.ClassDoc, pw:java.io.PrintWriter, fileDeepness:int)
- writeUMLStereotype(name:java.lang.String, pw:java.io.PrintWriter)
- fileFor(clazz:com.sun.javadoc.ClassDoc) : java.io.File
- fileFor(p:com.sun.javadoc.PackageDoc) : java.io.File
- packageFileFor(name:java.lang.String) : java.io.File
- directoryDeepness(clazz:com.sun.javadoc.ClassDoc) : int
- directoryDeepness(p:com.sun.javadoc.PackageDoc) : int
- toId(emd:com.sun.javadoc.ExecutableMemberDoc) : java.lang.String
- startFile(f:java.io.File, title:java.lang.String, fileDeepness:int) : java.io.PrintWriter
- finishFile(pw:java.io.PrintWriter)
- writeStylesheet(os:java.io.OutputStream)

Fields

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.

Constructors

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.

Methods

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, java.io.PrintWriter pw)
Writes the full documentation for a class.
private void writePackage(com.sun.javadoc.PackageDoc pack, java.io.PrintWriter 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, java.io.PrintWriter 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, java.io.PrintWriter pw)
Writes documentation for a field.
private void writeConstructor(com.sun.javadoc.ConstructorDoc con, java.io.PrintWriter pw)
Writes documentation for a constructor.
private void writeMethod(com.sun.javadoc.MethodDoc meth, java.io.PrintWriter pw)
Writes documentation for a method.
private void writeExecutableMemberComment(com.sun.javadoc.ExecutableMemberDoc emd, java.io.PrintWriter 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, java.io.PrintWriter pw)
Writes a UML class diagram. Parameter clazz: the class to write diagram of.
private void writeUMLVisability(com.sun.javadoc.MemberDoc m, java.io.PrintWriter 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, java.io.PrintWriter 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, java.io.PrintWriter pw)
Writes field as UML attribute.
private void writeParametersCode(com.sun.javadoc.Parameter[] a, java.io.PrintWriter 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, java.io.PrintWriter pw, int fileDeepness)
Writes an item in a line-up of parameters.
private void writeThrowsCode(com.sun.javadoc.ClassDoc[] exceptions, java.io.PrintWriter 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, java.io.PrintWriter 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, java.io.PrintWriter 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, java.io.PrintWriter pw)
Writes UML stereotype. Parameter name: the stereotype name.
private java.io.File 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 java.io.File 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 java.io.File 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 java.io.PrintWriter startFile(java.io.File f, java.lang.String title, int fileDeepness) throws java.io.IOException
Begins an XHTML output file. Parameter f: the file to begin. Parameter title: the title of the document.
private void finishFile(java.io.PrintWriter pw) throws java.io.IOException
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(java.io.OutputStream os) throws java.io.IOException
Writes stylesheet to specified stream. Parameter os: the stream to write the stylesheet file contents to.