org.umlgraph.doclet
Class ClassGraph

Show UML class diagram
java.lang.Object
  extended by org.umlgraph.doclet.ClassGraph
Direct Known Subclasses:
ContextMatcher.ClassGraphHack

 class ClassGraph
extends java.lang.Object

Class graph generation engine


Nested Class Summary
(package private) static class ClassGraph.Align
           
private static class ClassGraph.FieldRelationInfo
           
(package private) static class ClassGraph.Font
           
 
Field Summary
static java.util.Map<RelationType,java.lang.String> associationMap
           
protected  java.util.Map<java.lang.String,ClassInfo> classnames
           
protected  com.sun.javadoc.ClassDoc collectionClassDoc
           
protected  com.sun.javadoc.Doc contextDoc
           
protected static char FILE_SEPARATOR
           
protected  java.lang.String linePostfix
           
protected  java.lang.String linePrefix
           
protected  com.sun.javadoc.ClassDoc mapClassDoc
           
protected  OptionProvider optionProvider
           
protected  java.util.Map<java.lang.String,com.sun.javadoc.ClassDoc> rootClassdocs
           
protected  java.util.Set<java.lang.String> rootClasses
           
protected  java.io.PrintWriter w
           
 
Constructor Summary
ClassGraph(com.sun.javadoc.RootDoc root, OptionProvider optionProvider, com.sun.javadoc.Doc contextDoc)
          Create a new ClassGraph.
 
Method Summary
private  void allRelation(Options opt, RelationType rt, com.sun.javadoc.ClassDoc from)
          Print all relations for a given's class's tag
private  void attributes(Options opt, com.sun.javadoc.FieldDoc[] fd)
          Print the class's attributes fd
protected static java.lang.String buildRelativePath(java.lang.String contextPackageName, java.lang.String classPackageName)
           
 java.lang.String classToUrl(com.sun.javadoc.ClassDoc cd, boolean rootClass)
          Convert the class name into a corresponding URL
 java.lang.String classToUrl(java.lang.String className)
          Convert the class name into a corresponding URL
 void epilogue()
          Dot epilogue
private  java.lang.String escape(java.lang.String s)
          Escape <, >, and & characters in the string with the corresponding HTML entity code.
private  void externalTableEnd()
           
private  void externalTableStart(Options opt, java.lang.String name, java.lang.String url)
           
private
<T extends com.sun.javadoc.ProgramElementDoc>
java.util.List<T>
filterByVisibility(T[] docs, Visibility visibility)
          Returns all program element docs that have a visibility greater or equal than the specified level
private  void firstInnerTableEnd(Options opt, int nRows)
          End the first inner table of a class.
private  void firstInnerTableStart(Options opt, int nRows)
          Start the first inner table of a class.
private  java.lang.String fontWrap(java.lang.String text, Options opt, ClassGraph.Font font)
          Wraps the text with the appropriate font according to the specified font type
private  java.lang.String fontWrap(java.lang.String text, java.lang.String fontName, double fontSize)
          Wraps the text with the appropriate font tags when the font name and size are not void
protected  ClassInfo getClassInfo(java.lang.String className)
           
private  ClassGraph.FieldRelationInfo getFieldRelationInfo(com.sun.javadoc.FieldDoc field)
           
private  com.sun.javadoc.Type[] getInterfaceTypeArguments(com.sun.javadoc.ClassDoc iface, com.sun.javadoc.Type t)
           
private  java.lang.String getNodeName(com.sun.javadoc.ClassDoc c)
           
private  java.lang.String getNodeName(java.lang.String c)
          Return a class's internal name
private  java.lang.String getPackageName(java.lang.String className)
           
private  java.lang.String getUnqualifiedName(java.lang.String className)
           
private  java.lang.String guillemize(Options opt, java.lang.String s)
          Convert < and > characters in the string to the respective guillemot characters.
private  java.lang.String guilWrap(Options opt, java.lang.String str)
          Wraps a string in Guillemot (or an ASCII substitute) characters.
private  boolean hidden(com.sun.javadoc.ProgramElementDoc c)
          Return true if c has a @hidden tag associated with it
private  boolean hidden(java.lang.String s)
          Return true if the class name is associated to an hidden class or matches a hide expression
private  java.lang.String htmlNewline(java.lang.String s)
          Convert embedded newlines into HTML line breaks
private  void innerTableEnd()
           
private  void innerTableStart()
           
private  java.lang.String mapApiDocRoot(java.lang.String className)
          Returns the appropriate URL "root" for a given class name.
private  ClassInfo newClassInfo(java.lang.String className, boolean printed, boolean hidden)
           
private  void nodeProperties(Options opt)
          Print the common class node's properties
private  boolean operations(Options opt, com.sun.javadoc.ConstructorDoc[] m)
          Print the class's constructors m
private  boolean operations(Options opt, com.sun.javadoc.MethodDoc[] m)
          Print the class's operations m
private  java.lang.String parameter(Options opt, com.sun.javadoc.Parameter[] p)
          Print the method parameter p
 java.lang.String printClass(com.sun.javadoc.ClassDoc c, boolean rootClass)
          Prints the class if needed.
 void printExtraClasses(com.sun.javadoc.RootDoc root)
          Print classes that were parts of relationships, but not parsed by javadoc
 void printInferredDependencies(com.sun.javadoc.ClassDoc c)
          Prints dependencies recovered from the methods of a class.
 void printInferredDependencies(com.sun.javadoc.ClassDoc[] classes)
          Prints dependencies recovered from the methods of a class.
 void printInferredRelations(com.sun.javadoc.ClassDoc c)
          Prints associations recovered from the fields of a class.
 void printInferredRelations(com.sun.javadoc.ClassDoc[] classes)
          Prints associations recovered from the fields of a class.
 void printRelations(com.sun.javadoc.ClassDoc c)
          Print a class's relations
 void prologue()
          Dot prologue
private  java.lang.String qualifiedName(Options opt, java.lang.String r)
          Return the class's name, possibly by stripping the leading path
private  void relation(Options opt, RelationType rt, com.sun.javadoc.ClassDoc from, com.sun.javadoc.ClassDoc to, java.lang.String tailLabel, java.lang.String label, java.lang.String headLabel)
          Print the specified relation
private  void relation(Options opt, RelationType rt, com.sun.javadoc.ClassDoc from, java.lang.String fromName, com.sun.javadoc.ClassDoc to, java.lang.String toName, java.lang.String tailLabel, java.lang.String label, java.lang.String headLabel)
          Print the specified relation
private  java.lang.String relationNode(com.sun.javadoc.ClassDoc c)
          Return the full name of a relation's node.
private  java.lang.String relationNode(com.sun.javadoc.ClassDoc c, java.lang.String cName)
          Return the full name of a relation's node c.
private  java.lang.String removeTemplate(java.lang.String name)
          Removes the template specs from a class name.
private  void stereotype(Options opt, com.sun.javadoc.Doc c, ClassGraph.Align align)
          Return as a string the stereotypes associated with c terminated by the escape character term
private  void tableLine(ClassGraph.Align align, java.lang.String text)
           
private  void tableLine(ClassGraph.Align align, java.lang.String text, Options opt, ClassGraph.Font font)
           
private  void tagvalue(Options opt, com.sun.javadoc.Doc c)
          Return as a string the tagged values associated with c
private  java.lang.String type(Options opt, com.sun.javadoc.Type t)
          Print a a basic type t
private  java.lang.String typeAnnotation(Options opt, com.sun.javadoc.Type t)
          Annotate an field/argument with its type t
private  java.lang.String typeParameters(Options opt, com.sun.javadoc.ParameterizedType t)
          Print the parameters of the parameterized type t
private  java.lang.String visibility(Options opt, com.sun.javadoc.ProgramElementDoc e)
          Print the visibility adornment of element e prefixed by any stereotypes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FILE_SEPARATOR

protected static final char FILE_SEPARATOR
See Also:
Constant Field Values

associationMap

public static java.util.Map<RelationType,java.lang.String> associationMap

classnames

protected java.util.Map<java.lang.String,ClassInfo> classnames

rootClasses

protected java.util.Set<java.lang.String> rootClasses

rootClassdocs

protected java.util.Map<java.lang.String,com.sun.javadoc.ClassDoc> rootClassdocs

optionProvider

protected OptionProvider optionProvider

w

protected java.io.PrintWriter w

collectionClassDoc

protected com.sun.javadoc.ClassDoc collectionClassDoc

mapClassDoc

protected com.sun.javadoc.ClassDoc mapClassDoc

linePostfix

protected java.lang.String linePostfix

linePrefix

protected java.lang.String linePrefix

contextDoc

protected com.sun.javadoc.Doc contextDoc
Constructor Detail

ClassGraph

public ClassGraph(com.sun.javadoc.RootDoc root,
                  OptionProvider optionProvider,
                  com.sun.javadoc.Doc contextDoc)
Create a new ClassGraph.

The packages passed as an argument are the ones specified on the command line.

Local URLs will be generated for these packages.

Parameters:
root - The root of docs as provided by the javadoc API
optionProvider - The main option provider
contextDoc - The current context for generating relative links, may be a ClassDoc or a PackageDoc (used by UMLDoc)
Method Detail

qualifiedName

private java.lang.String qualifiedName(Options opt,
                                       java.lang.String r)
Return the class's name, possibly by stripping the leading path


escape

private java.lang.String escape(java.lang.String s)
Escape <, >, and & characters in the string with the corresponding HTML entity code.


htmlNewline

private java.lang.String htmlNewline(java.lang.String s)
Convert embedded newlines into HTML line breaks


guillemize

private java.lang.String guillemize(Options opt,
                                    java.lang.String s)
Convert < and > characters in the string to the respective guillemot characters.


guilWrap

private java.lang.String guilWrap(Options opt,
                                  java.lang.String str)
Wraps a string in Guillemot (or an ASCII substitute) characters.

Parameters:
str - the String to be wrapped.
Returns:
the wrapped String.

visibility

private java.lang.String visibility(Options opt,
                                    com.sun.javadoc.ProgramElementDoc e)
Print the visibility adornment of element e prefixed by any stereotypes


parameter

private java.lang.String parameter(Options opt,
                                   com.sun.javadoc.Parameter[] p)
Print the method parameter p


type

private java.lang.String type(Options opt,
                              com.sun.javadoc.Type t)
Print a a basic type t


typeParameters

private java.lang.String typeParameters(Options opt,
                                        com.sun.javadoc.ParameterizedType t)
Print the parameters of the parameterized type t


typeAnnotation

private java.lang.String typeAnnotation(Options opt,
                                        com.sun.javadoc.Type t)
Annotate an field/argument with its type t


attributes

private void attributes(Options opt,
                        com.sun.javadoc.FieldDoc[] fd)
Print the class's attributes fd


operations

private boolean operations(Options opt,
                           com.sun.javadoc.ConstructorDoc[] m)
Print the class's constructors m


operations

private boolean operations(Options opt,
                           com.sun.javadoc.MethodDoc[] m)
Print the class's operations m


nodeProperties

private void nodeProperties(Options opt)
Print the common class node's properties


tagvalue

private void tagvalue(Options opt,
                      com.sun.javadoc.Doc c)
Return as a string the tagged values associated with c

Parameters:
opt - the Options used to guess font names
c - the Doc entry to look for @tagvalue
prevterm - the termination string for the previous element
term - the termination character for each tagged value

stereotype

private void stereotype(Options opt,
                        com.sun.javadoc.Doc c,
                        ClassGraph.Align align)
Return as a string the stereotypes associated with c terminated by the escape character term


hidden

private boolean hidden(com.sun.javadoc.ProgramElementDoc c)
Return true if c has a @hidden tag associated with it


getClassInfo

protected ClassInfo getClassInfo(java.lang.String className)

newClassInfo

private ClassInfo newClassInfo(java.lang.String className,
                               boolean printed,
                               boolean hidden)

hidden

private boolean hidden(java.lang.String s)
Return true if the class name is associated to an hidden class or matches a hide expression


printClass

public java.lang.String printClass(com.sun.javadoc.ClassDoc c,
                                   boolean rootClass)
Prints the class if needed.

A class is a rootClass if it's included among the classes returned by RootDoc.classes(), this information is used to properly compute relative links in diagrams for UMLDoc


getNodeName

private java.lang.String getNodeName(com.sun.javadoc.ClassDoc c)

getNodeName

private java.lang.String getNodeName(java.lang.String c)
Return a class's internal name


allRelation

private void allRelation(Options opt,
                         RelationType rt,
                         com.sun.javadoc.ClassDoc from)
Print all relations for a given's class's tag

Parameters:
tagname - the tag containing the given relation
from - the source class
edgetype - the dot edge specification

relation

private void relation(Options opt,
                      RelationType rt,
                      com.sun.javadoc.ClassDoc from,
                      java.lang.String fromName,
                      com.sun.javadoc.ClassDoc to,
                      java.lang.String toName,
                      java.lang.String tailLabel,
                      java.lang.String label,
                      java.lang.String headLabel)
Print the specified relation

Parameters:
from - the source class (may be null)
fromName - the source class's name
to - the destination class (may be null)
toName - the destination class's name

relation

private void relation(Options opt,
                      RelationType rt,
                      com.sun.javadoc.ClassDoc from,
                      com.sun.javadoc.ClassDoc to,
                      java.lang.String tailLabel,
                      java.lang.String label,
                      java.lang.String headLabel)
Print the specified relation

Parameters:
from - the source class
to - the destination class

relationNode

private java.lang.String relationNode(com.sun.javadoc.ClassDoc c)
Return the full name of a relation's node. This may involve appending the port :p for the standard nodes whose outline is rendered through an inner table.


relationNode

private java.lang.String relationNode(com.sun.javadoc.ClassDoc c,
                                      java.lang.String cName)
Return the full name of a relation's node c. This may involve appending the port :p for the standard nodes whose outline is rendered through an inner table.

Parameters:
c - the node's class (may be null)
cName - the node's class name

printRelations

public void printRelations(com.sun.javadoc.ClassDoc c)
Print a class's relations


printExtraClasses

public void printExtraClasses(com.sun.javadoc.RootDoc root)
Print classes that were parts of relationships, but not parsed by javadoc


printInferredRelations

public void printInferredRelations(com.sun.javadoc.ClassDoc[] classes)
Prints associations recovered from the fields of a class. An association is inferred only if another relation between the two classes is not already in the graph.

Parameters:
classes -

printInferredRelations

public void printInferredRelations(com.sun.javadoc.ClassDoc c)
Prints associations recovered from the fields of a class. An association is inferred only if another relation between the two classes is not already in the graph.

Parameters:
classes -

printInferredDependencies

public void printInferredDependencies(com.sun.javadoc.ClassDoc[] classes)
Prints dependencies recovered from the methods of a class. A dependency is inferred only if another relation between the two classes is not already in the graph.

Parameters:
classes -

printInferredDependencies

public void printInferredDependencies(com.sun.javadoc.ClassDoc c)
Prints dependencies recovered from the methods of a class. A dependency is inferred only if another relation between the two classes is not already in the graph.

Parameters:
classes -

filterByVisibility

private <T extends com.sun.javadoc.ProgramElementDoc> java.util.List<T> filterByVisibility(T[] docs,
                                                                                           Visibility visibility)
Returns all program element docs that have a visibility greater or equal than the specified level


getFieldRelationInfo

private ClassGraph.FieldRelationInfo getFieldRelationInfo(com.sun.javadoc.FieldDoc field)

getInterfaceTypeArguments

private com.sun.javadoc.Type[] getInterfaceTypeArguments(com.sun.javadoc.ClassDoc iface,
                                                         com.sun.javadoc.Type t)

removeTemplate

private java.lang.String removeTemplate(java.lang.String name)
Removes the template specs from a class name.


classToUrl

public java.lang.String classToUrl(com.sun.javadoc.ClassDoc cd,
                                   boolean rootClass)
Convert the class name into a corresponding URL


buildRelativePath

protected static java.lang.String buildRelativePath(java.lang.String contextPackageName,
                                                    java.lang.String classPackageName)

getPackageName

private java.lang.String getPackageName(java.lang.String className)

getUnqualifiedName

private java.lang.String getUnqualifiedName(java.lang.String className)

classToUrl

public java.lang.String classToUrl(java.lang.String className)
Convert the class name into a corresponding URL


mapApiDocRoot

private java.lang.String mapApiDocRoot(java.lang.String className)
Returns the appropriate URL "root" for a given class name. The root will be used as the prefix of the URL used to link the class in the final diagram to the associated JavaDoc page.


prologue

public void prologue()
              throws java.io.IOException
Dot prologue

Throws:
java.io.IOException

epilogue

public void epilogue()
Dot epilogue


externalTableStart

private void externalTableStart(Options opt,
                                java.lang.String name,
                                java.lang.String url)

externalTableEnd

private void externalTableEnd()

innerTableStart

private void innerTableStart()

firstInnerTableStart

private void firstInnerTableStart(Options opt,
                                  int nRows)
Start the first inner table of a class.

Parameters:
nRows - the total number of rows in this table.

innerTableEnd

private void innerTableEnd()

firstInnerTableEnd

private void firstInnerTableEnd(Options opt,
                                int nRows)
End the first inner table of a class.

Parameters:
nRows - the total number of rows in this table.

tableLine

private void tableLine(ClassGraph.Align align,
                       java.lang.String text)

tableLine

private void tableLine(ClassGraph.Align align,
                       java.lang.String text,
                       Options opt,
                       ClassGraph.Font font)

fontWrap

private java.lang.String fontWrap(java.lang.String text,
                                  Options opt,
                                  ClassGraph.Font font)
Wraps the text with the appropriate font according to the specified font type

Parameters:
opt -
text -
font -
Returns:

fontWrap

private java.lang.String fontWrap(java.lang.String text,
                                  java.lang.String fontName,
                                  double fontSize)
Wraps the text with the appropriate font tags when the font name and size are not void

Parameters:
text - the text to be wrapped
fontName - considered void when it's null
fontSize - considered void when it's <= 0