You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by vs...@apache.org on 2007/11/01 14:28:51 UTC

svn commit: r590997 - in /maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src: main/java/org/apache/maven/jxr/java/doc/ main/resources/org/apache/maven/jxr/java/doc/ test/java/org/apache/maven/jxr/java/doc/

Author: vsiveton
Date: Thu Nov  1 06:28:51 2007
New Revision: 590997

URL: http://svn.apache.org/viewvc?rev=590997&view=rev
Log:
o improved the generated UML class diagram
o added xsl parameters: 
- show for the visibility of attributes and operations
- javasrcPath to link to xref dir
- javadocPath to link to javadoc dir
- diagramLabel
- diagramEncoding
o updated test cases

Modified:
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/doc/GenerateUMLDoc.java
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/doc/UmlDocTask.java
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/resources/org/apache/maven/jxr/java/doc/xml2dot.xsl
    maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/test/java/org/apache/maven/jxr/java/doc/UmlDocTaskTest.java

Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/doc/GenerateUMLDoc.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/doc/GenerateUMLDoc.java?rev=590997&r1=590996&r2=590997&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/doc/GenerateUMLDoc.java (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/doc/GenerateUMLDoc.java Thu Nov  1 06:28:51 2007
@@ -31,6 +31,8 @@
 import java.util.List;
 import java.util.TimeZone;
 
+import javax.xml.transform.OutputKeys;
+
 import org.apache.maven.jxr.util.DotTask;
 import org.apache.maven.jxr.util.DotTask.DotNotPresentInPathBuildException;
 import org.apache.tools.ant.BuildException;
@@ -53,21 +55,53 @@
  */
 public class GenerateUMLDoc
 {
+    private static final String NOW = new GregorianCalendar( TimeZone.getDefault() ).getTime().toString();
+
     /** Source directory */
     private File srcDir;
 
+    /** Source file encoding name, ISO-8859-1 is the default. */
+    private String encoding = "ISO-8859-1";
+
     /** Output file of the diagram */
     private File out;
 
-    /** Temp javadoc xml file */
-    private File javadocXml;
+    /** The class diagram encoding, ISO-8859-1 is the default. */
+    private String diagramEncoding = "ISO-8859-1";
+
+    /** The class diagram label */
+    private String diagramLabel = "Class Diagram (Generated by Maven on " + NOW + ")";
+
+    /** Relative path or URI to the generated Javadoc directory. */
+    private String javadocPath = "";
 
-    /** Temp xsl file */
+    /** Relative path or URI to the generated Java Xref directory. */
+    private String javasrcPath = "";
+
+    /** Temp XSL file. */
     private File xml2dot;
 
+    /** Temp javadoc xml file */
+    private File javadocXml;
+
     /** Temp generated dot file */
     private File dot;
 
+    /**
+     * Specifies the access level for classes and members to show in the generated class diagram.
+     * Possible values are:
+     * <ul>
+     * <li>public: shows only public classes and members</li>
+     * <li>protected: shows only public and protected classes and members</li>
+     * <li>package: shows all classes and members not marked private</li>
+     * <li>private: shows all classes and members</li>
+     * <li>"" (i.e. empty): nothing</li>
+     * </ul>
+     *
+     * Default value is protected.
+     */
+    private String show = "protected";
+
     /** Specify verbose information */
     private boolean verbose;
 
@@ -128,6 +162,56 @@
     }
 
     /**
+     * Getter for the diagramEncoding
+     *
+     * @return the diagramEncoding
+     */
+    public String getDiagramEncoding()
+    {
+        return this.diagramEncoding;
+    }
+
+    /**
+     * Getter for the diagramLabel
+     *
+     * @return the diagramLabel
+     */
+    public String getDiagramLabel()
+    {
+        return this.diagramLabel;
+    }
+
+    /**
+     * Getter for the encoding
+     *
+     * @return the encoding
+     */
+    public String getEncoding()
+    {
+        return this.encoding;
+    }
+
+    /**
+     * Getter for the javadocPath
+     *
+     * @return the relative path or URI to the generated javadoc directory
+     */
+    public String getJavadocPath()
+    {
+        return this.javadocPath;
+    }
+
+    /**
+     * Getter for the javasrcPath
+     *
+     * @return the relative path or URI to the generated javasrc directory
+     */
+    public String getJavasrcPath()
+    {
+        return this.javasrcPath;
+    }
+
+    /**
      * Getter for the destDir
      *
      * @return the destDir
@@ -138,6 +222,23 @@
     }
 
     /**
+     * Getter for the show. Possible values are:
+     * <ul>
+     * <li>public: shows only public classes and members</li>
+     * <li>protected: shows only public and protected classes and members</li>
+     * <li>package: shows all classes and members not marked private</li>
+     * <li>private: shows all classes and members</li>
+     * <li>"" (i.e. empty): nothing</li>
+     * </ul>
+     *
+     * @return the show
+     */
+    public String getShow()
+    {
+        return this.show;
+    }
+
+    /**
      * Getter for the srcDir
      *
      * @return the srcDir
@@ -158,6 +259,56 @@
     }
 
     /**
+     * Setter for the diagramEncoding
+     *
+     * @param diagramEncoding the diagramEncoding to set
+     */
+    public void setDiagramEncoding( String diagramEncoding )
+    {
+        this.diagramEncoding = diagramEncoding;
+    }
+
+    /**
+     * Setter for the diagramLabel
+     *
+     * @param diagramLabel the diagramLabel to set
+     */
+    public void setDiagramLabel( String diagramLabel )
+    {
+        this.diagramLabel = diagramLabel;
+    }
+
+    /**
+     * Setter for the encoding
+     *
+     * @param encoding the encoding to set
+     */
+    public void setEncoding( String encoding )
+    {
+        this.encoding = encoding;
+    }
+
+    /**
+     * Setter for the javadocPath
+     *
+     * @param javadocPath the relative path or URI to the generated javadoc directory
+     */
+    public void setJavadocPath( String javadocPath )
+    {
+        this.javadocPath = javadocPath;
+    }
+
+    /**
+     * Setter for the javasrcPath
+     *
+     * @param javasrcPath the relative path or URI to the generated javasrc directory
+     */
+    public void setJavasrcPath( String javasrcPath )
+    {
+        this.javasrcPath = javasrcPath;
+    }
+
+    /**
      * Setter for the destDir
      *
      * @param destDir the destDir to set
@@ -168,6 +319,23 @@
     }
 
     /**
+     * Setter for the show.  Possible values are:
+     * <ul>
+     * <li>public: shows only public classes and members</li>
+     * <li>protected: shows only public and protected classes and members</li>
+     * <li>package: shows all classes and members not marked private</li>
+     * <li>private: shows all classes and members</li>
+     * <li>"" (i.e. empty): nothing</li>
+     * </ul>
+     *
+     * @param show the show to set
+     */
+    public void setShow( String show )
+    {
+        this.show = show;
+    }
+
+    /**
      * Setter for the srcDir
      *
      * @param srcDir the srcDir to set
@@ -198,7 +366,8 @@
     {
         if ( this.javadocXml == null )
         {
-            this.javadocXml = new File( getOut().getParentFile(), "javadoc.xml" );
+            this.javadocXml = new File( getOut().getParentFile(), FileUtils.removeExtension( getOut().getName() )
+                + ".javadoc.xml" );
             if ( !isVerbose() )
             {
                 this.javadocXml.deleteOnExit();
@@ -215,7 +384,8 @@
     {
         if ( this.dot == null )
         {
-            this.dot = new File( getOut().getParentFile(), "javadoc.dot" );
+            this.dot = new File( getOut().getParentFile(), FileUtils.removeExtension( getOut().getName() )
+                + ".javadoc.dot" );
             if ( !isVerbose() )
             {
                 this.dot.deleteOnExit();
@@ -237,7 +407,7 @@
     }
 
     /**
-     * @return xsl temp file.
+     * @return the xml2dot XSL file.
      * @throws IOException if any
      */
     private File getXml2dot()
@@ -245,7 +415,8 @@
     {
         if ( this.xml2dot == null )
         {
-            this.xml2dot = new File( getOut().getParentFile(), "xml2dot.xsl" );
+            this.xml2dot = new File( getOut().getParentFile(), FileUtils.removeExtension( getOut().getName() )
+                + ".xml2dot.xsl" );
             if ( !isVerbose() )
             {
                 this.xml2dot.deleteOnExit();
@@ -284,9 +455,16 @@
             + "**/.cvsignore,**/SCCS,**/SCCS/**,**/vssver.scc,**/.svn,**/.svn/**,**/.DS_Store";
 
         List args = new LinkedList();
-        args.add( "-package" );
+        args.add( "-private" );
         args.add( "-sourcepath" );
         args.add( srcDir.getAbsolutePath() );
+        if ( StringUtils.isNotEmpty( getEncoding() ) )
+        {
+            args.add( "-encoding" );
+            args.add( getEncoding() );
+            args.add( "-xmlencoding" );
+            args.add( getEncoding() );
+        }
         args.add( "-o" );
         args.add( getJavadocXml().getAbsolutePath() );
         List packages = FileUtils.getDirectoryNames( srcDir, null, defaultExcludes, false );
@@ -328,8 +506,6 @@
     private void generateJavadocDot()
         throws BuildException, IOException
     {
-        String now = new GregorianCalendar( TimeZone.getDefault() ).getTime().toString();
-
         XSLTProcess xsltTask = new XSLTProcess();
         xsltTask.setProject( getAntProject() );
         xsltTask.setTaskName( "xslt" );
@@ -337,10 +513,44 @@
         xsltTask.setIn( getJavadocXml() );
         xsltTask.setOut( getDot() );
         xsltTask.setStyle( getXml2dot().getAbsolutePath() );
+
+        if ( StringUtils.isNotEmpty( getDiagramEncoding() ) )
+        {
+            XSLTProcess.OutputProperty prop = xsltTask.createOutputProperty();
+            prop.setName( OutputKeys.ENCODING );
+            prop.setValue( getDiagramEncoding() );
+        }
+
         Param param = xsltTask.createParam();
         param.setProject( getAntProject() );
         param.setName( "now" );
-        param.setExpression( now );
+        param.setExpression( NOW );
+
+        param = xsltTask.createParam();
+        param.setProject( getAntProject() );
+        param.setName( "diagramEncoding" );
+        param.setExpression( ( getDiagramEncoding() == null ? "" : getDiagramEncoding() ) );
+
+        param = xsltTask.createParam();
+        param.setProject( getAntProject() );
+        param.setName( "show" );
+        param.setExpression( ( getShow() == null ? "" : getShow() ) );
+
+        param = xsltTask.createParam();
+        param.setProject( getAntProject() );
+        param.setName( "javasrcPath" );
+        param.setExpression( ( getJavasrcPath() == null ? "" : getJavasrcPath() ) );
+
+        param = xsltTask.createParam();
+        param.setProject( getAntProject() );
+        param.setName( "javadocPath" );
+        param.setExpression( ( getJavadocPath() == null ? "" : getJavadocPath() ) );
+
+        param = xsltTask.createParam();
+        param.setProject( getAntProject() );
+        param.setName( "diagramLabel" );
+        param.setExpression( ( getDiagramLabel() == null ? "" : getDiagramLabel() ) );
+
         xsltTask.execute();
     }
 
@@ -361,7 +571,7 @@
         }
         else
         {
-            format = "png";
+            format = "svg";
         }
 
         DotTask dotTask = new DotTask();

Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/doc/UmlDocTask.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/doc/UmlDocTask.java?rev=590997&r1=590996&r2=590997&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/doc/UmlDocTask.java (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/java/org/apache/maven/jxr/java/doc/UmlDocTask.java Thu Nov  1 06:28:51 2007
@@ -26,6 +26,7 @@
 import org.apache.tools.ant.BuildException;
 import org.apache.tools.ant.Project;
 import org.apache.tools.ant.Task;
+import org.codehaus.plexus.util.StringUtils;
 
 /**
  * <a href="http://ant.apache.org/">Ant</a> task to generate UML diagram.
@@ -44,6 +45,36 @@
     /** Output file of the diagram*/
     private File out;
 
+    /** Source file encoding name. */
+    private String encoding;
+
+    /**
+     * Specifies the access level for classes and members to show in the generated class diagram.
+     * Possible values are:
+     * <ul>
+     * <li>public: shows only public classes and members</li>
+     * <li>protected: shows only public and protected classes and members</li>
+     * <li>package: shows all classes and members not marked private</li>
+     * <li>private: shows all classes and members</li>
+     * <li>"" (i.e. empty): nothing</li>
+     * </ul>
+     *
+     * Default value is protected.
+     */
+    private String show;
+
+    /** Relative path or URI to the generated Javadoc directory. */
+    private String javadocPath;
+
+    /** Relative path or URI to the generated Java Xref directory. */
+    private String javasrcPath;
+
+    /** The class diagram encoding. */
+    private String diagramEncoding;
+
+    /** The class diagram label */
+    private String diagramLabel;
+
     /** Specify verbose information */
     private boolean verbose;
 
@@ -51,13 +82,63 @@
     private boolean failOnError;
 
     /**
-     * Set the Java source directory.
+     * Set fail on an error.
      *
-     * @param d Path to the directory.
+     * @param b true to fail on an error.
      */
-    public void setSrcDir( File d )
+    public void setFailonerror( boolean b )
     {
-        this.srcDir = d;
+        this.failOnError = b;
+    }
+
+    /**
+     * Set the class diagram encoding.
+     *
+     * @param diagramEncoding the class diagram encoding.
+     */
+    public void setDiagramEncoding( String diagramEncoding )
+    {
+        this.diagramEncoding = diagramEncoding;
+    }
+
+    /**
+     * Set the class diagram label.
+     *
+     * @param diagramLabel the class diagram label.
+     */
+    public void setDiagramLabel( String diagramLabel )
+    {
+        this.diagramLabel = diagramLabel;
+    }
+
+    /**
+     * Set the source file encoding name.
+     *
+     * @param encoding the source file encoding name.
+     */
+    public void setEncoding( String encoding )
+    {
+        this.encoding = encoding;
+    }
+
+    /**
+     * Set the generated Javadoc directory.
+     *
+     * @param javadocPath the relative path or URI to the generated javadoc directory
+     */
+    public void setJavadocPath( String javadocPath )
+    {
+        this.javadocPath = javadocPath;
+    }
+
+    /**
+     * Set the generated JavaSrc source directory.
+     *
+     * @param javasrcPath the relative path or URI to the generated javasrc directory
+     */
+    public void setJavasrcPath( String javasrcPath )
+    {
+        this.javasrcPath = javasrcPath;
     }
 
     /**
@@ -71,23 +152,40 @@
     }
 
     /**
-     * Setter for the verbose
+     * Set the access level for classes and members. Possible values are:
+     * <ul>
+     * <li>public: shows only public classes and members</li>
+     * <li>protected: shows only public and protected classes and members</li>
+     * <li>package: shows all classes and members not marked private</li>
+     * <li>private: shows all classes and members</li>
+     * <li>"" (i.e. empty): nothing</li>
+     * </ul>
      *
-     * @param verbose the verbose to set
+     * @param show new access level.
      */
-    public void setVerbose( boolean verbose )
+    public void setShow( String show )
     {
-        this.verbose = verbose;
+        this.show = show;
     }
 
     /**
-     * Set fail on an error.
+     * Set the Java source directory.
      *
-     * @param b true to fail on an error.
+     * @param d Path to the directory.
      */
-    public void setFailonerror( boolean b )
+    public void setSrcDir( File d )
     {
-        this.failOnError = b;
+        this.srcDir = d;
+    }
+
+    /**
+     * Setter for the verbose
+     *
+     * @param verbose the verbose to set
+     */
+    public void setVerbose( boolean verbose )
+    {
+        this.verbose = verbose;
     }
 
     /** {@inheritDoc} */
@@ -116,7 +214,31 @@
         try
         {
             GenerateUMLDoc generator = new GenerateUMLDoc( getSrcDir(), getOut() );
+            if ( StringUtils.isNotEmpty( this.encoding ) )
+            {
+                generator.setEncoding( this.encoding );
+            }
             generator.setVerbose( this.verbose );
+            if ( this.show != null )
+            {
+                generator.setShow( this.show );
+            }
+            if ( StringUtils.isNotEmpty( this.javadocPath ) )
+            {
+                generator.setJavadocPath( this.javadocPath );
+            }
+            if ( StringUtils.isNotEmpty( this.javasrcPath ) )
+            {
+                generator.setJavasrcPath( this.javasrcPath );
+            }
+            if ( StringUtils.isNotEmpty( this.diagramEncoding ) )
+            {
+                generator.setDiagramEncoding( this.diagramEncoding );
+            }
+            if ( StringUtils.isNotEmpty( this.diagramLabel ) )
+            {
+                generator.setDiagramLabel( this.diagramLabel );
+            }
             generator.generateUML();
         }
         catch ( IllegalArgumentException e )

Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/resources/org/apache/maven/jxr/java/doc/xml2dot.xsl
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/resources/org/apache/maven/jxr/java/doc/xml2dot.xsl?rev=590997&r1=590996&r2=590997&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/resources/org/apache/maven/jxr/java/doc/xml2dot.xsl (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/main/resources/org/apache/maven/jxr/java/doc/xml2dot.xsl Thu Nov  1 06:28:51 2007
@@ -19,21 +19,61 @@
   <xsl:output method="text" omit-xml-declaration="yes"/>
 
   <xsl:param name="now"/>
+  <!--
+    show="public"    Show only public classes and members
+    show="protected" Show protected/public classes and members (default)
+    show="package"   Show package/protected/public classes and members
+    show="private"   Show all classes and members
+    show=""          Show nothing
+  -->
+  <xsl:param name="show"/>
+  <!--
+    javasrcPath      Relative path or URI to the generated Java Xref directory.
+  -->
+  <xsl:param name="javasrcPath"/>
+  <!--
+    javadocPath      Relative path or URI to the generated Javadoc directory.
+  -->
+  <xsl:param name="javadocPath"/>
+  <!--
+    diagramLabel     The label of the generated class diagram.
+  -->
+  <xsl:param name="diagramLabel"/>
+  <!--
+    diagramEncoding  The encoding of the generated class diagram.
+  -->
+  <xsl:param name="diagramEncoding"/>
 
   <xsl:template match="javadoc">
     <xsl:text>#
-# Class Diagram - Generated by Maven JXR on </xsl:text><xsl:value-of select="$now"/><xsl:text>
+# Class Diagram - Generated by Maven xml2dot on </xsl:text><xsl:value-of select="$now"/><xsl:text>
 #
 # @see http://www.graphviz.org/doc/libguide/libguide.pdf
 #
 
     digraph G {
-        // global settings
+        // global settings</xsl:text>
+      <xsl:if test="$diagramEncoding != ''">
+        <xsl:text>
+        charset = "</xsl:text>
+        <xsl:value-of select="$diagramEncoding"/>
+        <xsl:text>";</xsl:text>
+      </xsl:if>
+      <xsl:text>
         ranksep = "1.5";
         rankdir = "TB";
-        labeljust = "left";
+        labeljust = "center";
         labelloc = "bottom";
-        label = "Class Diagram";
+        label = "</xsl:text>
+        <xsl:choose>
+          <xsl:when test="$diagramLabel != ''">
+            <xsl:value-of select="$diagramLabel"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text>Class Diagram</xsl:text>
+          </xsl:otherwise>
+        </xsl:choose>
+        <xsl:text>";
 
         edge [fontname = "Helvetica", fontsize = "9", labelfontname = "Helvetica", labelfontsize = "9"];
         node [fontname = "Helvetica", fontsize = "9", shape = "record"];&#10;</xsl:text>
@@ -111,7 +151,8 @@
     <xsl:text> {
             labeljust = "center";
             labelloc = "top";
-            node [style = "filled"];</xsl:text>
+            node [style = "filled"];
+            z = "1";</xsl:text>
     <xsl:apply-templates/>
     <!-- rank same, min, max, source or sink
              rankdir TB LR (left to right) or TB (top to bottom)
@@ -129,8 +170,32 @@
             label = "</xsl:text>
     <xsl:value-of select="@name"/>
     <xsl:text>";
+            tooltip = "</xsl:text>
+    <xsl:value-of select="@name"/>
+    <xsl:if test="$javasrcPath != ''">
+      <xsl:text>";
+            URL = "</xsl:text>
+      <xsl:value-of select="$javasrcPath"/>
+      <xsl:call-template name="filepath">
+        <xsl:with-param name="name" select="../@name"/>
+        <xsl:with-param name="parentname" select="@name"/>
+      </xsl:call-template>
+      <xsl:text>/package-summary.html</xsl:text>
+    </xsl:if>
+    <xsl:if test="$javadocPath != ''">
+      <xsl:text>";
+        URL = "</xsl:text>
+      <xsl:value-of select="$javadocPath"/>
+      <xsl:call-template name="filepath">
+        <xsl:with-param name="name" select="../@name"/>
+        <xsl:with-param name="parentname" select="@name"/>
+      </xsl:call-template>
+      <xsl:text>/package-summary.html</xsl:text>
+    </xsl:if>
+    <xsl:text>";
             color = "#000000";
             fillcolor = "#dddddd";
+            style = "filled";
         }
 </xsl:text>
   </xsl:template>
@@ -158,83 +223,248 @@
     <!-- need to replace newline chars with \n -->
     <!--comment="<xsl:value-of select="doc" />" ,-->
     <xsl:text>
-            URL = "</xsl:text>
-    <xsl:call-template name="filepath">
+            tooltip = "</xsl:text>
+    <xsl:call-template name="name">
       <xsl:with-param name="name" select="../@name"/>
       <xsl:with-param name="parentname" select="@name"/>
     </xsl:call-template>
+    <xsl:if test="$javasrcPath != ''">
+      <xsl:text>",
+            URL = "</xsl:text>
+      <xsl:value-of select="$javasrcPath"/>
+      <xsl:call-template name="filepath">
+        <xsl:with-param name="name" select="../@name"/>
+        <xsl:with-param name="parentname" select="@name"/>
+      </xsl:call-template>
+      <xsl:text>_java.html</xsl:text>
+    </xsl:if>
     <xsl:text>",
             style = "filled",
             label = "{</xsl:text>
     <xsl:value-of select="@name"/>
+    <xsl:if test="@extensibility='abstract'">
+      <xsl:text> \{ abstract \} </xsl:text>
+    </xsl:if>
     <xsl:text>\n|</xsl:text>
-    <xsl:if test="show">
-      <xsl:for-each select="field">
+    <!-- attributes -->
+    <xsl:for-each select="field">
+      <xsl:if test="$show = 'private'">
         <xsl:choose>
           <xsl:when test="@access='public'">
-            <xsl:text>+</xsl:text>
+            <xsl:text> + </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='protected'">
+            <xsl:text> # </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='package'">
+            <xsl:text> ~ </xsl:text>
           </xsl:when>
           <xsl:when test="@access='private'">
-            <xsl:text>-</xsl:text>
+            <xsl:text> - </xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text/>
+          </xsl:otherwise>
+        </xsl:choose>
+
+        <xsl:if test="@access='public' or @access='protected' or @access='package' or @access='private'">
+          <xsl:call-template name="printAttribute"/>
+        </xsl:if>
+      </xsl:if>
+
+      <xsl:if test="$show = 'package'">
+        <xsl:choose>
+          <xsl:when test="@access='public'">
+            <xsl:text> + </xsl:text>
           </xsl:when>
           <xsl:when test="@access='protected'">
-            <xsl:text>#</xsl:text>
+            <xsl:text> # </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='package'">
+            <xsl:text> ~ </xsl:text>
           </xsl:when>
           <xsl:otherwise>
-            <xsl:text>/</xsl:text>
+            <xsl:text/>
           </xsl:otherwise>
         </xsl:choose>
-        <xsl:call-template name="substring-after-last">
-          <xsl:with-param name="input" select="returns/primitive/@type"/>
-          <xsl:with-param name="marker" select="'.'"/>
-        </xsl:call-template>
-        <xsl:call-template name="substring-after-last">
-          <xsl:with-param name="input" select="returns/classref/@name"/>
-          <xsl:with-param name="marker" select="'.'"/>
-        </xsl:call-template>
-        <xsl:text>\n</xsl:text>
-      </xsl:for-each>
-    </xsl:if>
+
+        <xsl:if test="@access='public' or @access='protected' or @access='package'">
+          <xsl:call-template name="printAttribute"/>
+        </xsl:if>
+      </xsl:if>
+
+      <xsl:if test="$show = 'protected'">
+        <xsl:choose>
+          <xsl:when test="@access='public'">
+            <xsl:text> + </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='protected'">
+            <xsl:text> # </xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text/>
+          </xsl:otherwise>
+        </xsl:choose>
+
+        <xsl:if test="@access='public' or @access='protected'">
+          <xsl:call-template name="printAttribute"/>
+        </xsl:if>
+      </xsl:if>
+
+      <xsl:if test="$show = 'public' and (@access='public')">
+        <xsl:text> + </xsl:text>
+
+        <xsl:call-template name="printAttribute"/>
+      </xsl:if>
+    </xsl:for-each>
+
     <xsl:text>|</xsl:text>
-    <xsl:if test="show">
-      <!-- constructor -->
-      <xsl:for-each select="method">
+
+    <!-- constructor -->
+    <xsl:for-each select="constructor">
+      <xsl:if test="$show = 'private'">
         <xsl:choose>
           <xsl:when test="@access='public'">
-            <xsl:text>+</xsl:text>
+            <xsl:text> + </xsl:text>
           </xsl:when>
           <xsl:when test="@access='private'">
-            <xsl:text>-</xsl:text>
+            <xsl:text> - </xsl:text>
           </xsl:when>
           <xsl:when test="@access='protected'">
-            <xsl:text>#</xsl:text>
+            <xsl:text> # </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='package'">
+            <xsl:text> ~ </xsl:text>
           </xsl:when>
           <xsl:otherwise>
-            <xsl:text>/</xsl:text>
+            <xsl:text/>
           </xsl:otherwise>
         </xsl:choose>
-        <xsl:call-template name="substring-after-last">
-          <xsl:with-param name="input" select="returns/primitive/@type"/>
-          <xsl:with-param name="marker" select="'.'"/>
-        </xsl:call-template>
-        <xsl:call-template name="substring-after-last">
-          <xsl:with-param name="input" select="returns/classref/@name"/>
-          <xsl:with-param name="marker" select="'.'"/>
-        </xsl:call-template>
-        <xsl:text> </xsl:text>
-        <xsl:value-of select="@name"/>
-        <xsl:text>( </xsl:text>
-        <xsl:for-each select="parameter">
-          <xsl:value-of select="primitive/@type"/>
-          <xsl:call-template name="substring-after-last">
-            <xsl:with-param name="input" select="classref/@name"/>
-            <xsl:with-param name="marker" select="'.'"/>
-          </xsl:call-template>
-          <xsl:text>,</xsl:text>
-        </xsl:for-each>
-        <xsl:text>)\n</xsl:text>
-      </xsl:for-each>
-    </xsl:if>
+
+        <xsl:if test="@access='public' or @access='protected' or @access='package' or @access='private'">
+          <xsl:call-template name="printConstructor"/>
+        </xsl:if>
+      </xsl:if>
+
+      <xsl:if test="$show = 'package'">
+        <xsl:choose>
+          <xsl:when test="@access='public'">
+            <xsl:text> + </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='protected'">
+            <xsl:text> # </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='package'">
+            <xsl:text> ~ </xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text/>
+          </xsl:otherwise>
+        </xsl:choose>
+
+        <xsl:if test="@access='public' or @access='protected' or @access='package'">
+          <xsl:call-template name="printConstructor"/>
+        </xsl:if>
+      </xsl:if>
+
+      <xsl:if test="$show = 'protected'">
+        <xsl:choose>
+          <xsl:when test="@access='public'">
+            <xsl:text> + </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='protected'">
+            <xsl:text> # </xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text/>
+          </xsl:otherwise>
+        </xsl:choose>
+
+        <xsl:if test="@access='public' or @access='protected'">
+          <xsl:call-template name="printConstructor"/>
+        </xsl:if>
+      </xsl:if>
+
+      <xsl:if test="$show = 'public' and @access='public'">
+        <xsl:text> + </xsl:text>
+
+        <xsl:call-template name="printConstructor"/>
+      </xsl:if>
+    </xsl:for-each>
+
+    <!-- methods -->
+    <xsl:for-each select="method">
+      <xsl:if test="$show = 'private'">
+        <xsl:choose>
+          <xsl:when test="@access='public'">
+            <xsl:text> + </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='private'">
+            <xsl:text> - </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='protected'">
+            <xsl:text> # </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='package'">
+            <xsl:text> ~ </xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text/>
+          </xsl:otherwise>
+        </xsl:choose>
+
+        <xsl:if test="@access='public' or @access='protected' or @access='package' or @access='private'">
+          <xsl:call-template name="printMethod"/>
+        </xsl:if>
+      </xsl:if>
+
+      <xsl:if test="$show = 'package'">
+        <xsl:choose>
+          <xsl:when test="@access='public'">
+            <xsl:text> + </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='protected'">
+            <xsl:text> # </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='package'">
+            <xsl:text> ~ </xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text/>
+          </xsl:otherwise>
+        </xsl:choose>
+
+        <xsl:if test="@access='public' or @access='protected' or @access='package'">
+          <xsl:call-template name="printMethod"/>
+        </xsl:if>
+      </xsl:if>
+
+      <xsl:if test="$show = 'protected'">
+        <xsl:choose>
+          <xsl:when test="@access='public'">
+            <xsl:text> + </xsl:text>
+          </xsl:when>
+          <xsl:when test="@access='protected'">
+            <xsl:text> # </xsl:text>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text/>
+          </xsl:otherwise>
+        </xsl:choose>
+
+        <xsl:if test="@access='public' or @access='protected'">
+          <xsl:call-template name="printMethod"/>
+        </xsl:if>
+      </xsl:if>
+
+      <xsl:if test="$show = 'public' and @access='public'">
+        <xsl:text> + </xsl:text>
+
+        <xsl:call-template name="printMethod"/>
+      </xsl:if>
+
+    </xsl:for-each>
+
     <xsl:text>}"
             ];</xsl:text>
   </xsl:template>
@@ -249,9 +479,25 @@
     <xsl:text> [
             color = "#9c0031",
             fillcolor = "#deffff",
-            label = "{«interface»\n</xsl:text>
+            label = "{\&lt;\&lt;interface\&gt;\&gt;\n</xsl:text>
     <xsl:value-of select="@name"/>
-    <xsl:text>\n}"
+
+    <xsl:text>|</xsl:text>
+    <!-- operations -->
+    <xsl:if test="$show = 'private' or $show = 'package' or $show = 'protected' or $show = 'public'">
+      <xsl:for-each select="method">
+        <xsl:choose>
+          <xsl:when test="@access='public'">
+            <xsl:text> + </xsl:text>
+            <xsl:call-template name="printMethod"/>
+          </xsl:when>
+          <xsl:otherwise>
+            <xsl:text/>
+          </xsl:otherwise>
+        </xsl:choose>
+      </xsl:for-each>
+    </xsl:if>
+    <xsl:text>}"
             ];</xsl:text>
   </xsl:template>
 
@@ -265,7 +511,118 @@
 
   <xsl:template match="method"/>
 
+  <xsl:template name="printAttribute">
+    <xsl:if test="@static='true'">
+      <xsl:text> $ </xsl:text>
+    </xsl:if>
+
+    <xsl:call-template name="substring-after-last">
+      <xsl:with-param name="input" select="@name"/>
+      <xsl:with-param name="marker" select="'.'"/>
+    </xsl:call-template>
+    <xsl:text> : </xsl:text>
+    <xsl:call-template name="substring-after-last">
+      <xsl:with-param name="input" select="primitive/@type"/>
+      <xsl:with-param name="marker" select="'.'"/>
+    </xsl:call-template>
+    <xsl:call-template name="substring-after-last">
+      <xsl:with-param name="input" select="classref/@name"/>
+      <xsl:with-param name="marker" select="'.'"/>
+    </xsl:call-template>
+
+    <xsl:if test="@final='true'">
+      <xsl:text> \{ final \} </xsl:text>
+    </xsl:if>
+
+    <xsl:text>\n</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="printConstructor">
+    <xsl:call-template name="substring-after-last">
+      <xsl:with-param name="input" select="@name"/>
+      <xsl:with-param name="marker" select="'.'"/>
+    </xsl:call-template>
+    <xsl:text>(</xsl:text>
+    <xsl:for-each select="parameter">
+      <xsl:value-of select="primitive/@type"/>
+      <xsl:call-template name="substring-after-last">
+        <xsl:with-param name="input" select="classref/@name"/>
+        <xsl:with-param name="marker" select="'.'"/>
+      </xsl:call-template>
+      <xsl:if test="not(position()=last())">
+        <xsl:text>, </xsl:text>
+      </xsl:if>
+    </xsl:for-each>
+    <xsl:text>)</xsl:text>
+
+    <xsl:text>\n</xsl:text>
+  </xsl:template>
+
+  <xsl:template name="printMethod">
+    <xsl:if test="@static='true'">
+      <xsl:text> $ </xsl:text>
+    </xsl:if>
+
+    <xsl:call-template name="substring-after-last">
+      <xsl:with-param name="input" select="@name"/>
+      <xsl:with-param name="marker" select="'.'"/>
+    </xsl:call-template>
+    <xsl:text>(</xsl:text>
+    <xsl:for-each select="parameter">
+      <xsl:value-of select="primitive/@type"/>
+      <xsl:call-template name="substring-after-last">
+        <xsl:with-param name="input" select="classref/@name"/>
+        <xsl:with-param name="marker" select="'.'"/>
+      </xsl:call-template>
+      <xsl:if test="not(position()=last())">
+        <xsl:text>, </xsl:text>
+      </xsl:if>
+    </xsl:for-each>
+    <xsl:text>) : </xsl:text>
+    <xsl:call-template name="substring-after-last">
+      <xsl:with-param name="input" select="returns/primitive/@type"/>
+      <xsl:with-param name="marker" select="'.'"/>
+    </xsl:call-template>
+    <xsl:call-template name="substring-after-last">
+      <xsl:with-param name="input" select="returns/classref/@name"/>
+      <xsl:with-param name="marker" select="'.'"/>
+    </xsl:call-template>
+
+    <xsl:if test="@extensibility='abstract' or @native='true' or @synchronized='true'">
+      <xsl:text> \{</xsl:text>
+    </xsl:if>
+    <xsl:if test="@extensibility='abstract'">
+      <xsl:text> abstract </xsl:text>
+    </xsl:if>
+    <xsl:if test="@native='true'">
+      <xsl:text> native </xsl:text>
+    </xsl:if>
+    <xsl:if test="@synchronized='true'">
+      <xsl:text> synchronized </xsl:text>
+    </xsl:if>
+    <xsl:if test="@extensibility='abstract' or @native='true' or @synchronized='true'">
+      <xsl:text>\} </xsl:text>
+    </xsl:if>
+
+    <xsl:text>\n</xsl:text>
+  </xsl:template>
+
   <!-- Utilities templates -->
+  <xsl:template name="name">
+    <xsl:param name="name"/>
+    <xsl:param name="parentname"/>
+    <xsl:call-template name="replace-string">
+      <xsl:with-param name="text" select="$name"/>
+      <xsl:with-param name="replace" select="'.'"/>
+      <xsl:with-param name="with" select="'.'"/>
+    </xsl:call-template>
+    <xsl:if test="$parentname!=''">.</xsl:if>
+    <xsl:call-template name="replace-string">
+      <xsl:with-param name="text" select="$parentname"/>
+      <xsl:with-param name="replace" select="'.'"/>
+      <xsl:with-param name="with" select="'.'"/>
+    </xsl:call-template>
+  </xsl:template>
 
   <xsl:template name="fullname">
     <xsl:param name="name"/>

Modified: maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/test/java/org/apache/maven/jxr/java/doc/UmlDocTaskTest.java
URL: http://svn.apache.org/viewvc/maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/test/java/org/apache/maven/jxr/java/doc/UmlDocTaskTest.java?rev=590997&r1=590996&r2=590997&view=diff
==============================================================================
--- maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/test/java/org/apache/maven/jxr/java/doc/UmlDocTaskTest.java (original)
+++ maven/sandbox/trunk/jxr/maven-jxr/maven-jxr-java/src/test/java/org/apache/maven/jxr/java/doc/UmlDocTaskTest.java Thu Nov  1 06:28:51 2007
@@ -22,6 +22,9 @@
 import java.io.File;
 
 import org.apache.tools.ant.Project;
+import org.apache.tools.ant.taskdefs.Copy;
+import org.apache.tools.ant.types.FileSet;
+import org.codehaus.plexus.util.PathTool;
 
 import junit.framework.TestCase;
 
@@ -32,6 +35,33 @@
 public class UmlDocTaskTest
     extends TestCase
 {
+    private static final String BASEDIR = new File( "" ).getAbsolutePath();
+
+    /** {@inheritDoc} */
+    protected void setUp()
+        throws Exception
+    {
+        File srcDir = new File( BASEDIR, "target/unit/src" );
+        if ( !srcDir.exists() )
+        {
+            Project antProject = new Project();
+            antProject.setBasedir( BASEDIR );
+
+            Copy copy = new Copy();
+            copy.setProject( antProject );
+            copy.setTodir( srcDir );
+            FileSet set = new FileSet();
+            set.setDir( new File( BASEDIR, "src/main/java" ) );
+            set.setIncludes( "**/*.java" );
+            copy.addFileset( set );
+            set = new FileSet();
+            set.setDir( new File( BASEDIR, "target/generated-sources/antlr" ) );
+            set.setIncludes( "**/*.java" );
+            copy.addFileset( set );
+            copy.execute();
+        }
+    }
+
     /**
      * Call UMLdoc task
      *
@@ -40,19 +70,46 @@
     public void testDefaultExecute()
         throws Exception
     {
-        final String basedir = new File( "" ).getAbsolutePath();
+        File out = new File( BASEDIR, "target/unit/umldoc-default/umlDefault.svg" );
+        File srcDir = new File( BASEDIR, "src/test/resources/javasrc" );
 
-        File out = new File( basedir, "target/unit/umldoc-default/uml.svg" );
-        File srcDir = new File( basedir, "src/test/resources/javasrc" );
+        Project antProject = new Project();
+        antProject.setBasedir( BASEDIR );
+
+        UmlDocTask task = new UmlDocTask();
+        task.setProject( antProject );
+        task.setSrcDir( srcDir );
+        task.setOut( out );
+        task.setVerbose( true );
+        task.setDiagramEncoding( "UTF-8" );
+        task.execute();
+
+        // Generated files
+        assertTrue( out.exists() );
+        assertTrue( out.length() > 0 );
+    }
+
+    /**
+     * Call UMLdoc task
+     *
+     * @throws Exception if any.
+     */
+    public void testLinkExecute()
+        throws Exception
+    {
+        File out = new File( BASEDIR, "target/unit/umldoc-default/umlLink.svg" );
+        File srcDir = new File( BASEDIR, "target/unit/src" );
 
         Project antProject = new Project();
-        antProject.setBasedir( basedir );
+        antProject.setBasedir( BASEDIR );
 
         UmlDocTask task = new UmlDocTask();
         task.setProject( antProject );
         task.setSrcDir( srcDir );
         task.setOut( out );
         task.setVerbose( true );
+        // All tests passed...
+        task.setJavasrcPath( PathTool.getRelativePath( "./target/unit/src" ) + "/target/unit/jxrdoc-default/" );
         task.execute();
 
         // Generated files