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 2009/09/05 16:27:46 UTC

svn commit: r811654 - /maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java

Author: vsiveton
Date: Sat Sep  5 14:27:45 2009
New Revision: 811654

URL: http://svn.apache.org/viewvc?rev=811654&view=rev
Log:
MPDF-30: Add a parameter to include or not the TOC

o follow r811653

Modified:
    maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java

Modified: maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java?rev=811654&r1=811653&r2=811654&view=diff
==============================================================================
--- maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java (original)
+++ maven/plugins/trunk/maven-pdf-plugin/src/main/java/org/apache/maven/plugins/pdf/PdfMojo.java Sat Sep  5 14:27:45 2009
@@ -321,13 +321,14 @@
     private boolean includeReports;
 
     /**
-     * If <code>true</false>, generate a TOC (Table Of Content) for all items defined in the &lt;toc/&gt; element from
-     * the document descriptor.
+     * Generate a TOC (Table Of Content) for all items defined in the &lt;toc/&gt; element from the document descriptor.
+     * <br/>
+     * Possible values are: 'none', 'start' and 'end'.
      *
-     * @parameter expression="${includeTOC}" default-value="true"
+     * @parameter expression="${generateTOC}" default-value="start"
      * @since 1.1
      */
-    private boolean includeTOC;
+    private String generateTOC;
 
     // ----------------------------------------------------------------------
     // Instance fields
@@ -383,19 +384,7 @@
     public void execute()
         throws MojoExecutionException, MojoFailureException
     {
-        if ( "fo".equalsIgnoreCase( implementation ) )
-        {
-            this.docRenderer = foRenderer;
-        }
-        else if ( "itext".equalsIgnoreCase( implementation ) )
-        {
-            this.docRenderer = itextRenderer;
-        }
-        else
-        {
-            throw new MojoFailureException( "Not a valid implementation: '" + implementation
-                + "'. Should be 'fo' or 'itext'." );
-        }
+        init();
 
         try
         {
@@ -419,6 +408,36 @@
     }
 
     /**
+     * Init and validate parameters
+     *
+     * @throws MojoFailureException if any
+     */
+    private void init()
+        throws MojoFailureException
+    {
+        if ( "fo".equalsIgnoreCase( implementation ) )
+        {
+            this.docRenderer = foRenderer;
+        }
+        else if ( "itext".equalsIgnoreCase( implementation ) )
+        {
+            this.docRenderer = itextRenderer;
+        }
+        else
+        {
+            throw new MojoFailureException( "Not a valid 'implementation' parameter: '" + implementation
+                + "'. Should be 'fo' or 'itext'." );
+        }
+
+        if ( !( "none".equalsIgnoreCase( generateTOC ) || "start".equalsIgnoreCase( generateTOC ) || "end"
+                                                                                                          .equalsIgnoreCase( generateTOC ) ) )
+        {
+            throw new MojoFailureException( "Not a valid 'generateTOC' parameter: '" + generateTOC
+                + "'. Should be 'none', 'start' or 'end'." );
+        }
+    }
+
+    /**
      * Copy the generated PDF to outputDirectory.
      *
      * @throws MojoExecutionException if any
@@ -532,7 +551,7 @@
             context.put( "FileUtils", new FileUtils() );
             context.put( "StringUtils", new StringUtils() );
             context.put( "i18n", i18n );
-            context.put( "includeTOC", Boolean.valueOf( includeTOC ) );
+            context.put( "generateTOC", generateTOC );
 
             try
             {