Author: dennisl
Date: Thu May 31 14:59:44 2007
New Revision: 543277

URL: http://svn.apache.org/viewvc?view=rev&rev=543277
Log:
o Refactor the creation of title and summary for the report into a couple of 
common methods in the parent.

Modified:
    
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
    
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/DeveloperActivityReport.java
    
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityReport.java
    
maven/plugins/trunk/maven-changelog-plugin/src/main/resources/scm-activity.properties

Modified: 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java?view=diff&rev=543277&r1=543276&r2=543277
==============================================================================
--- 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
 (original)
+++ 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/ChangeLogReport.java
 Thu May 31 14:59:44 2007
@@ -82,6 +82,13 @@
      */
     private static final String FILE_TOKEN = "%FILE%";
 
+    private static final String DEFAULT_DATE_PATTERN = "yyyy-MM-dd";
+
+    /**
+     * Formatter used for dates.
+     */
+    private static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat( 
DEFAULT_DATE_PATTERN );
+
     /**
      * Used to specify whether to build the log using range, tag or date.
      *
@@ -263,11 +270,11 @@
      * <ul>
      * <li><code>%FILE%</code> - this is the path to a file</li>
      * </ul>
-     * <p/>
+     * <p>
      * Example:
      * 
<code>http://checkstyle.cvs.sourceforge.net/checkstyle%FILE%?view=markup</code>
      * </p>
-     * <p/>
+     * <p>
      * <strong>Note:</strong> If you don't supply the token in your template,
      * the path of the file will simply be appended to your template URL.
      * </p>
@@ -319,8 +326,8 @@
 
         if ( outputXML.exists() )
         {
-            if ( outputXMLExpiration > 0 &&
-                outputXMLExpiration * 60000 > System.currentTimeMillis() - 
outputXML.lastModified() )
+            if ( outputXMLExpiration > 0
+                && outputXMLExpiration * 60000 > System.currentTimeMillis() - 
outputXML.lastModified() )
             {
                 try
                 {
@@ -732,8 +739,8 @@
         }
         else
         {
-            throw new MavenReportException( "The type parameter has an invalid 
value: " + type +
-                ".  The value should be \"range\", \"date\", or \"tag\"." );
+            throw new MavenReportException( "The type parameter has an invalid 
value: " + type
+                + ".  The value should be \"range\", \"date\", or \"tag\"." );
         }
     }
 
@@ -836,6 +843,24 @@
     {
         sink.section1();
 
+        doChangeSetTitle( set, bundle, sink );
+
+        doSummary( set, bundle, sink );
+
+        doChangedSetTable( set.getChangeSets(), bundle, sink );
+
+        sink.section1_();
+    }
+
+    /**
+     * Generate the title for the report.
+     *
+     * @param set    change set to generate the report from
+     * @param bundle the resource bundle to retrieve report phrases from
+     * @param sink   the report formatting tool
+     */
+    protected void doChangeSetTitle( ChangeLogSet set, ResourceBundle bundle, 
Sink sink )
+    {
         sink.sectionTitle2();
         if ( set.getStartDate() == null )
         {
@@ -844,15 +869,26 @@
         else if ( set.getEndDate() == null )
         {
             sink.text( bundle.getString( "report.SetRangeSince" ) );
-            sink.text( " " + set.getStartDate() );
+            sink.text( " " + DATE_FORMAT.format( set.getStartDate() ) );
         }
         else
         {
             sink.text( bundle.getString( "report.SetRangeBetween" ) );
-            sink.text( " " + set.getStartDate() + " " + bundle.getString( 
"report.To" ) + " " + set.getEndDate() );
+            sink.text( " " + DATE_FORMAT.format( set.getStartDate() ) + " " + 
bundle.getString( "report.And" ) + " "
+                + DATE_FORMAT.format( set.getEndDate() ) );
         }
         sink.sectionTitle2_();
+    }
 
+    /**
+     * Generate the summary section of the report.
+     *
+     * @param set    change set to generate the report from
+     * @param bundle the resource bundle to retrieve report phrases from
+     * @param sink   the report formatting tool
+     */
+    protected void doSummary( ChangeLogSet set, ResourceBundle bundle, Sink 
sink )
+    {
         sink.paragraph();
         sink.text( bundle.getString( "report.TotalCommits" ) );
         sink.text( ": " + set.getChangeSets().size() );
@@ -860,10 +896,6 @@
         sink.text( bundle.getString( "report.changelog.FilesChanged" ) );
         sink.text( ": " + countFilesChanged( set.getChangeSets() ) );
         sink.paragraph_();
-
-        doChangedSetTable( set.getChangeSets(), bundle, sink );
-
-        sink.section1_();
     }
 
     /**

Modified: 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/DeveloperActivityReport.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/DeveloperActivityReport.java?view=diff&rev=543277&r1=543276&r2=543277
==============================================================================
--- 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/DeveloperActivityReport.java
 (original)
+++ 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/DeveloperActivityReport.java
 Thu May 31 14:59:44 2007
@@ -163,20 +163,9 @@
     private void doChangedSets( ChangeLogSet set, ResourceBundle bundle, Sink 
sink )
     {
         sink.section2();
-        sink.sectionTitle2();
-        if ( set.getStartDate() == null )
-        {
-            sink.text( bundle.getString( "report.SetRangeUnknown" ) );
-        }
-        else if ( set.getEndDate() == null )
-        {
-            sink.text( bundle.getString( "report.SetRangeSince" ) );
-        }
-        else
-        {
-            sink.text( " " + set.getStartDate() + " " + bundle.getString( 
"report.To" ) + " " + set.getEndDate() );
-            sink.sectionTitle2_();
-        }
+
+        doChangeSetTitle( set, bundle, sink );
+
         doSummary( set, bundle, sink );
 
         sink.table();
@@ -198,29 +187,6 @@
         sink.table_();
 
         sink.section2_();
-    }
-
-    /**
-     * generates the report summary section of the report
-     *
-     * @param set    changed set to generate the report from
-     * @param bundle the resource bundle to retrieve report phrases from
-     * @param sink   the report formatting tool
-     */
-    private void doSummary( ChangeLogSet set, ResourceBundle bundle, Sink sink 
)
-    {
-        sink.paragraph();
-
-        sink.text( bundle.getString( "report.dev-activity.range" ) );
-        sink.text( ": " + set.getStartDate() + " " + bundle.getString( 
"report.To" ) + " " + set.getEndDate() );
-
-        sink.text( ", " + bundle.getString( "report.TotalCommits" ) );
-        sink.text( ":" + set.getChangeSets().size() );
-
-        sink.text( ", " + bundle.getString( "report.dev-activity.filesChanged" 
) );
-        sink.text( ":" + countFilesChanged( set.getChangeSets() ) );
-
-        sink.paragraph_();
     }
 
     /**

Modified: 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityReport.java
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityReport.java?view=diff&rev=543277&r1=543276&r2=543277
==============================================================================
--- 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityReport.java
 (original)
+++ 
maven/plugins/trunk/maven-changelog-plugin/src/main/java/org/apache/maven/plugin/changelog/FileActivityReport.java
 Thu May 31 14:59:44 2007
@@ -141,22 +141,9 @@
     private void doChangedSets( ChangeLogSet set, ResourceBundle bundle, Sink 
sink )
     {
         sink.section2();
-        sink.sectionTitle2();
-        if ( set.getStartDate() == null )
-        {
-            sink.text( bundle.getString( "report.SetRangeUnknown" ) );
-        }
-        else if ( set.getEndDate() == null )
-        {
-            sink.text( bundle.getString( "report.SetRangeSince" ) );
-        }
-        else
-        {
-            sink.text( bundle.getString( "report.SetRangeBetween" ) );
-            sink.text( " " + set.getStartDate() + " " + bundle.getString( 
"report.To" ) + " " + set.getEndDate() );
-        }
-        sink.sectionTitle2_();
 
+        doChangeSetTitle( set, bundle, sink );
+        
         doSummary( set, bundle, sink );
 
         sink.table();
@@ -175,29 +162,6 @@
         sink.table_();
 
         sink.section2_();
-    }
-
-    /**
-     * generates the report summary section of the report
-     *
-     * @param set    changed set to generate the report from
-     * @param bundle the resource bundle to retrieve report phrases from
-     * @param sink   the report formatting tool
-     */
-    private void doSummary( ChangeLogSet set, ResourceBundle bundle, Sink sink 
)
-    {
-        sink.paragraph();
-
-        sink.text( bundle.getString( "report.file-activity.range" ) );
-        sink.text( ": " + set.getStartDate() + " " + bundle.getString( 
"report.To" ) + " " + set.getEndDate() );
-
-        sink.text( ", " + bundle.getString( "report.TotalCommits" ) );
-        sink.text( ":" + set.getChangeSets().size() );
-
-        sink.text( ", " + bundle.getString( 
"report.file-activity.filesChanged" ) );
-        sink.text( ":" + countFilesChanged( set.getChangeSets() ) );
-
-        sink.paragraph_();
     }
 
     /**

Modified: 
maven/plugins/trunk/maven-changelog-plugin/src/main/resources/scm-activity.properties
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-changelog-plugin/src/main/resources/scm-activity.properties?view=diff&rev=543277&r1=543276&r2=543277
==============================================================================
--- 
maven/plugins/trunk/maven-changelog-plugin/src/main/resources/scm-activity.properties
 (original)
+++ 
maven/plugins/trunk/maven-changelog-plugin/src/main/resources/scm-activity.properties
 Thu May 31 14:59:44 2007
@@ -16,6 +16,7 @@
 # under the License.
 
 #Commons
+report.And=and
 report.SetRangeUnknown=Changes from an unknown range
 report.SetRangeSince=Changes since
 report.SetRangeBetween=Changes between


Reply via email to