⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jdepend.jsl

📁 数据仓库工具
💻 JSL
字号:
<?xml version="1.0"?>

<jsl:stylesheet
  select="$doc"
  xmlns:j="jelly:core"
  xmlns:jsl="jelly:jsl"
  xmlns:x="jelly:xml"
  xmlns:define="jelly:define"
  xmlns:util="jelly:util"
  xmlns:doc="doc"
  xmlns:jdepend="jdepend"
  trim="false">

  <!-- This needs to be instantiated here to be available in the template matches -->
  <j:useBean var="mavenTool" class="org.apache.maven.MavenTool"/>
  <j:useBean var="htmlescape" class="org.apache.velocity.anakia.Escape"/>
  <j:useBean var="fileutil" class="org.apache.velocity.texen.util.FileUtil"/>
  <j:useBean var="pathtool" class="org.apache.maven.DVSLPathTool"/>
  <j:useBean var="stringTool" class="org.apache.maven.StringTool"/>

  <define:taglib uri="jdepend">
    <define:tag name="nav">
      <p>
        [
        <a href="#Summary">summary</a>]
        [
        <a href="#Packages">packages</a>]
        [
        <a href="#Cycles">cycles</a>]
        [
        <a href="#Explanations">explanations</a>]
      </p>
    </define:tag>
    <!--
     | Used to print the abstract and concrete classes that a package
     | contains.  Also removes the leading package information from
     | the fully qualified class (to conserve screen space).  Also,
     | creates a link to the xref sources so users can quickly navigate
     | the code.
    -->
    <define:tag name="classes">
      <j:choose>
        <j:when test="${currentNode.get(xpath) != null}">
          <i>None</i>
        </j:when>
        <j:otherwise>
          <j:forEach var="class" items="${currentNode.selectNodes(xpath)}">
            <!-- class.StringValue =~ org.apache.maven.SomeClass -->
            <j:set var="packageName">${stringTool.splitStringAtLastDelim(class.StringValue.trim(), '.').get(0)}</j:set>
            <j:set var="className">${stringTool.splitStringAtLastDelim(class.StringValue.trim(), '.').get(1)}</j:set>
            <util:replace var="dir" oldChar="." newChar="/" value="${packageName}"/>
            
            <j:choose>
              <j:when test="${class.attribute('sourceFile') != null}">
                <j:set var="classSourceFile" value="${class.attribute('sourceFile').getValue()}"/>
                <j:set var="classSourceFile" value="${stringTool.splitStringAtLastDelim(classSourceFile, '.').get(0)}"/>
              
                <a href="xref/${dir}/${classSourceFile}.html">${className}</a>
              </j:when>
              <j:otherwise>
                <a href="xref/${dir}/${className}.html">${className}</a>
              </j:otherwise>
            </j:choose>
          
            <br/>
          </j:forEach>
        </j:otherwise>
      </j:choose>
    </define:tag>
    <!--
     | Used to print the "used" and "used by" packages.  Also, creates a
     | link to the appropriate package in the report.
    -->
    <define:tag name="packages">
      <j:choose>
        <j:when test="${currentNode.get(xpath) != null}">
          <i>None</i>
        </j:when>
        <j:otherwise>
          <j:forEach var="class" items="${currentNode.selectNodes(xpath)}">
            <a href="#${class.getStringValue()}">${class.getStringValue()}</a>
            <br/>
          </j:forEach>
        </j:otherwise>
      </j:choose>
    </define:tag>
  </define:taglib>

  <jsl:template match="JDepend">
    <document>

      <properties>
        <title>JDepend Source Code Analysis</title>
      </properties>

      <body>
        <section name="Metric Results">
          <jdepend:nav/>
          <p>
            The following document contains the results of a
            <a
              href="http://www.clarkware.com/software/JDepend.html">JDepend</a>
            metric analysis.  The various metrics are defined at the bottom
            of this document.
          </p>
        </section>

        <section name="Summary">
          <jdepend:nav/>
          <table>
            <tr>
              <th>Package</th>
              <th>
                <font size="-1">Total 
                <br/>Classes</font>
              </th>
              <th>
                <font size="-1">Abstract
                  <br/>Classes
                </font>
              </th>
              <th>
                <font size="-1">Concrete
                  <br/>Classes
                </font>
              </th>
              <th>
                <font size="-1">Afferent
                  <br/>Couplings
                </font>
              </th>
              <th>
                <font size="-1">Efferent
                  <br/>Couplings
                </font>
              </th>
              <th>
                <font size="-1">Abstractness</font>
              </th>
              <th>
                <font size="-1">Instability</font>
              </th>
              <th>
                <font size="-1">Distance</font>
              </th>
            </tr>

            <x:set var="packages" select="Packages/Package"/>
            <j:forEach var="package" items="${packages}">
              <!-- Is this the only way I can tell if an element has a value properly? -->
              <j:set var="error" value="${package.valueOf('error').trim()}"/>
              <j:if test="${error == ''}">
                <tr>
                  <td>
                    <a href="#${package.attribute('name').getValue()}">${package.attribute('name').getValue()}</a>
                  </td>
                  <td align="right">
                    <x:expr select="$package/Stats/TotalClasses"/>
                  </td>
                  <td><x:expr select="$package/Stats/AbstractClasses"/></td>
                  <td><x:expr select="$package/Stats/ConcreteClasses"/></td>
                  <td><x:expr select="$package/Stats/Ca"/></td>
                  <td><x:expr select="$package/Stats/Ce"/></td>
                  <td>
                    <j:set var="display"><x:expr select="$package/Stats/A"/></j:set>
                    <doc:formatAsNumber string="${display}" pattern="#.##"/>
                  </td>
                  <td>
                    <j:set var="display"><x:expr select="$package/Stats/I"/></j:set>
                    <doc:formatAsNumber string="${display}" pattern="#%"/>
                  </td>
                  <td>
                    <j:set var="display"><x:expr select="$package/Stats/D"/></j:set>
                    <doc:formatAsNumber string="${display}" pattern="#%"/>
                  </td>
                </tr>
              </j:if>
            </j:forEach>

          </table>
        </section>

        <section name="Packages">
          <jdepend:nav/>

          <j:forEach var="package" items="${packages}">
            <!-- Is this the only way I can tell if an element has a value properly? -->
            <j:set var="error" value="${package.valueOf('error').trim()}"/>
            <j:if test="${error == ''}">
              <subsection name="${package.attribute('name').getValue()}">
                <table>
                  <tr>
                    <th>Afferent Couplings</th>
                    <th>Efferent Couplings</th>
                    <th>Abstractness</th>
                    <th>Instability</th>
                    <th>Distance</th>
                  </tr>
                  <tr>
                    <td>${package.valueOf("Stats/Ca")}</td>
                    <td>${package.valueOf("Stats/Ce")}</td>
                    <td>
                      <doc:formatAsNumber string="${package.valueOf('Stats/A')}" pattern="#%"/>
                    </td>
                    <td>
                      <doc:formatAsNumber string="${package.valueOf('Stats/I')}" pattern="#%"/>
                    </td>
                    <td>
                      <doc:formatAsNumber string="${package.valueOf('Stats/D')}" pattern="#%"/>
                    </td>
                  </tr>
                </table>

                <table>
                  <tr>
                    <th>Abstract Classes</th>
                    <th>Concrete Classes</th>
                    <th>Used by Packages</th>
                    <th>Uses Packages</th>
                  </tr>
                  <tr>
                    <td>
                      <jdepend:classes currentNode="${package}" xpath="AbstractClasses/Class"/>
                    </td>
                    <td>
                      <jdepend:classes currentNode="${package}" xpath="ConcreteClasses/Class"/>
                    </td>
                    <td>
                      <jdepend:packages currentNode="${package}" xpath="UsedBy/Package"/>
                    </td>
                    <td>
                      <jdepend:packages currentNode="${package}" xpath="DependsUpon/Package"/>
                    </td>
                  </tr>
                </table>
              </subsection>
            </j:if>
          </j:forEach>
        </section>

        <section name="Cycles">
          <jdepend:nav/>
          <x:set var="packages" select="Cycles/Package"/>
          <j:choose>
            <j:when test="${size(packages) == 0}">
              <p>There are no cyclic dependancies.</p>
            </j:when>
            <j:otherwise>
              <table>
                <tr>
                  <th>Package</th>
                  <th>Cyclic Dependencies</th>
                </tr>
                
                <j:forEach var="package" items="${packages}">
                  <tr>
                    <td>${package.attribute('Name').getValue()}</td>
                    <td>
                      <x:set var="cycles" select="$package/Package"/> 
                      <j:forEach var="cycle" items="${cycles}">
                        ${cycle.getText()}
                        <br/>
                      </j:forEach>
                    </td>
                  </tr>
                </j:forEach>
              </table>
            </j:otherwise>
          </j:choose>
        </section>

        <section name="Explanations">
          <jdepend:nav/>

          <p>
            The following explanations are for quick reference and are
            lifted directly from the original
            <a
              href="http://www.clarkware.com/software/JDepend.html">JDepend
              documentation</a>.
          </p>

          <table>
            <tr>
              <th>Term</th>
              <th>Description</th>
            </tr>
            <tr>
              <td>Number of Classes</td>
              <td>
                The number of concrete and abstract classes (and interfaces)
                in the package is an indicator of the extensibility of the
                package.
              </td>
            </tr>
            <tr>
              <td>Afferent Couplings</td>
              <td>
                The number of other packages that depend upon classes within
                the package is an indicator of the package's responsibility.
              </td>
            </tr>
            <tr>
              <td>Efferent Couplings</td>
              <td>
                The number of other packages that the classes in the package
                depend upon is an indicator of the package's independence.
              </td>
            </tr>
            <tr>
              <td>Abstractness</td>
              <td>
                The ratio of the number of abstract classes (and interfaces)
                in the analyzed package to the total number of classes in
                the analyzed package.  The range for this metric is 0 to 1,
                with A=0 indicating a completely concrete package and A=1
                indicating a completely abstract package.
              </td>
            </tr>
            <tr>
              <td>Instability</td>
              <td>
                The ratio of efferent coupling (Ce) to total coupling (Ce /
                (Ce + Ca)). This metric is an indicator of the package's
                resilience to change.  The range for this metric is 0 to 1,
                with I=0 indicating a completely stable package and I=1
                indicating a completely instable package.
              </td>
            </tr>
            <tr>
              <td>Distance</td>
              <td>
                The perpendicular distance of a package from the idealized
                line A + I = 1. This metric is an indicator of the package's
                balance between abstractness and stability.  A package
                squarely on the main sequence is optimally balanced with
                respect to its abstractness and stability. Ideal packages
                are either completely abstract and stable (x=0, y=1) or
                completely concrete and instable (x=1, y=0).  The range for
                this metric is 0 to 1, with D=0 indicating a package that is
                coincident with the main sequence and D=1 indicating a
                package that is as far from the main sequence as possible.
              </td>
            </tr>
            <tr>
              <td>Cycles</td>
              <td>
                Packages participating in a package dependency cycle are in
                a deadly embrace with respect to reusability and their
                release cycle. Package dependency cycles can be easily
                identified by reviewing the textual reports of dependency
                cycles. Once these dependency cycles have been identified
                with JDepend, they can be broken by employing various
                object-oriented techniques.
              </td>
            </tr>
          </table>
        </section>

      </body>
    </document>

  </jsl:template>
</jsl:stylesheet>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -