gr.spinellis.umlgraph.doclet
Class ClassGraph

Package class diagram package ClassGraph
java.lang.Object
  extended by gr.spinellis.umlgraph.doclet.ClassGraph
Direct Known Subclasses:
ContextMatcher.ClassGraphHack

 class ClassGraph
extends 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 Map<RelationType,String> associationMap
           
protected  Map<String,ClassInfo> classnames
           
protected  ClassDoc collectionClassDoc
           
protected  Doc contextDoc
           
protected static char FILE_SEPARATOR
           
protected  String linePostfix
           
protected  String linePrefix
           
protected  ClassDoc mapClassDoc
           
protected  OptionProvider optionProvider
           
protected  Set<String> rootClasses
           
protected  PrintWriter w
           
 
Constructor Summary
ClassGraph(RootDoc root, OptionProvider optionProvider, Doc contextDoc)
          Create a new ClassGraph.
 
Method Summary
private  void attributes(Options opt, FieldDoc[] fd)
          Print the class's attributes fd
protected static String buildRelativePath(String contextPackageName, String classPackageName)
           
 String classToUrl(ClassDoc cd, boolean rootClass)
          Convert the class name into a corresponding URL
 String classToUrl(String className)
          Convert the class name into a corresponding URL
 void epilogue()
          Dot epilogue
private  String escape(String s)
          Escape <, >, and & characters in the string with the corresponding HTML entity code.
private  void externalTableEnd()
           
private  void externalTableStart(Options opt, String name, String url)
           
private
<T extends ProgramElementDoc>
List<T>
filterByVisibility(T[] docs, Visibility visibility)
          Returns all program element docs that have a visibility greater or equal than the specified level
private  String fontWrap(String text, Options opt, ClassGraph.Font font)
          Wraps the text with the appropriate font according to the specified font type
private  String fontWrap(String text, String fontName, double fontSize)
          Wraps the text with the appropriate font tags when the font name and size are not void
protected  ClassInfo getClassInfo(String className)
           
private  ClassGraph.FieldRelationInfo getFieldRelationInfo(FieldDoc field)
           
private  Type[] getInterfaceTypeArguments(ClassDoc iface, Type t)
           
private  String getNodeName(ClassDoc c)
           
private  String getNodeName(String c)
          Return a class's internal name
private  String guillemize(Options opt, String s)
          Convert < and > characters in the string to the respective guillemot characters.
private  String guilWrap(Options opt, String str)
          Wraps a string in Guillemot (or an ASCII substitute) characters.
private  boolean hidden(ProgramElementDoc c)
          Return true if c has a @hidden tag associated with it
private  boolean hidden(String s)
          Return true if the class name is associated to an hidden class or matches a hide expression
private  void innerTableEnd()
           
private  void innerTableStart()
           
private  String mapApiDocRoot(String className)
          Returns the appropriate URL "root" for a given class name.
private  ClassInfo newClassInfo(String className, boolean printed, boolean hidden)
           
private  void nodeProperties(Options opt)
          Print the common class node's properties
private  boolean operations(Options opt, ConstructorDoc[] m)
          Print the class's constructors m
private  boolean operations(Options opt, MethodDoc[] m)
          Print the class's operations m
private  String parameter(Options opt, Parameter[] p)
          Print the method parameter p
 String printClass(ClassDoc c, boolean rootClass)
          Prints the class if needed.
 void printExtraClasses(RootDoc root)
          Print classes that were parts of relationships, but not parsed by javadoc
 void printInferredDependencies(ClassDoc c)
          Prints dependencies recovered from the methods of a class.
 void printInferredDependencies(ClassDoc[] classes)
          Prints dependencies recovered from the methods of a class.
 void printInferredRelations(ClassDoc c)
          Prints associations recovered from the fields of a class.
 void printInferredRelations(ClassDoc[] classes)
          Prints associations recovered from the fields of a class.
 void printRelations(ClassDoc c)
          Print a class's relations
 void prologue()
          Dot prologue
private  String qualifiedName(Options opt, String r)
          Return the class's name, possibly by stripping the leading path
private  void relation(Options opt, RelationType rt, ClassDoc from, String fromName)
          Print all relations for a given's class's tag
private  void relation(Options opt, RelationType rt, String from, String fromName, String dest, String destName, String tailLabel, String label, String headLabel)
           
private  String removeTemplate(String name)
          Removes the template specs from a class name.
private  void stereotype(Options opt, 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, String text)
           
private  void tableLine(ClassGraph.Align align, String text, Options opt, ClassGraph.Font font)
           
private  void tagvalue(Options opt, Doc c)
          Return as a string the tagged values associated with c
private  String type(Options opt, Type t)
          Print a a basic type t
private  String typeAnnotation(Options opt, Type t)
          Annotate an field/argument with its type t
private  String typeParameters(Options opt, ParameterizedType t)
          Print the parameters of the parameterized type t
private  String visibility(Options opt, 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 Map<RelationType,String> associationMap

classnames

protected Map<String,ClassInfo> classnames

rootClasses

protected Set<String> rootClasses

optionProvider

protected OptionProvider optionProvider

w

protected PrintWriter w

collectionClassDoc

protected ClassDoc collectionClassDoc

mapClassDoc

protected ClassDoc mapClassDoc

linePostfix

protected String linePostfix

linePrefix

protected String linePrefix

contextDoc

protected Doc contextDoc
Constructor Detail

ClassGraph

public ClassGraph(RootDoc root,
                  OptionProvider optionProvider,
                  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 String qualifiedName(Options opt,
                             String r)
Return the class's name, possibly by stripping the leading path


escape

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


guillemize

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


guilWrap

private String guilWrap(Options opt,
                        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 String visibility(Options opt,
                          ProgramElementDoc e)
Print the visibility adornment of element e prefixed by any stereotypes


parameter

private String parameter(Options opt,
                         Parameter[] p)
Print the method parameter p


type

private String type(Options opt,
                    Type t)
Print a a basic type t


typeParameters

private String typeParameters(Options opt,
                              ParameterizedType t)
Print the parameters of the parameterized type t


typeAnnotation

private String typeAnnotation(Options opt,
                              Type t)
Annotate an field/argument with its type t


attributes

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


operations

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


operations

private boolean operations(Options opt,
                           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,
                      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,
                        Doc c,
                        ClassGraph.Align align)
Return as a string the stereotypes associated with c terminated by the escape character term


hidden

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


getClassInfo

protected ClassInfo getClassInfo(String className)

newClassInfo

private ClassInfo newClassInfo(String className,
                               boolean printed,
                               boolean hidden)

hidden

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


printClass

public String printClass(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 String getNodeName(ClassDoc c)

getNodeName

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


relation

private void relation(Options opt,
                      RelationType rt,
                      ClassDoc from,
                      String fromName)
Print all relations for a given's class's tag

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

relation

private void relation(Options opt,
                      RelationType rt,
                      String from,
                      String fromName,
                      String dest,
                      String destName,
                      String tailLabel,
                      String label,
                      String headLabel)

printRelations

public void printRelations(ClassDoc c)
Print a class's relations


printExtraClasses

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


printInferredRelations

public void printInferredRelations(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(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(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(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 ProgramElementDoc> 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(FieldDoc field)

getInterfaceTypeArguments

private Type[] getInterfaceTypeArguments(ClassDoc iface,
                                         Type t)

removeTemplate

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


classToUrl

public String classToUrl(ClassDoc cd,
                         boolean rootClass)
Convert the class name into a corresponding URL


buildRelativePath

protected static String buildRelativePath(String contextPackageName,
                                          String classPackageName)

classToUrl

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


mapApiDocRoot

private String mapApiDocRoot(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 IOException
Dot prologue

Throws:
IOException

epilogue

public void epilogue()
Dot epilogue


externalTableStart

private void externalTableStart(Options opt,
                                String name,
                                String url)

externalTableEnd

private void externalTableEnd()

innerTableStart

private void innerTableStart()

innerTableEnd

private void innerTableEnd()

tableLine

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

tableLine

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

fontWrap

private String fontWrap(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 String fontWrap(String text,
                        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