View Javadoc

1   package org.apache.maven.report.projectinfo;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.doxia.sink.Sink;
23  import org.apache.maven.reporting.AbstractMavenReportRenderer;
24  
25  import java.util.Locale;
26  
27  /**
28   * Generates the project index page.
29   *
30   * @author <a href="mailto:brett@apache.org">Brett Porter </a>
31   * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton </a>
32   * @version $Id: ProjectIndexPageReport.java 728546 2008-12-21 22:56:51Z bentmann $
33   * @since 2.0
34   * @goal index
35   */
36  public class ProjectIndexPageReport
37      extends AbstractProjectInfoReport
38  {
39      // ----------------------------------------------------------------------
40      // Public methods
41      // ----------------------------------------------------------------------
42  
43      /** {@inheritDoc} */
44      public String getName( Locale locale )
45      {
46          return i18n.getString( "project-info-report", locale, "report.index.title" );
47      }
48  
49      /** {@inheritDoc} */
50      public String getDescription( Locale locale )
51      {
52          String desc;
53          if ( project.getDescription() != null )
54          {
55              // TODO How to handle i18n?
56              desc = project.getDescription();
57          }
58          else
59          {
60              desc = i18n.getString( "project-info-report", locale, "report.index.nodescription" );
61          }
62          return desc;
63      }
64  
65      /** {@inheritDoc} */
66      public void executeReport( Locale locale )
67      {
68          ProjectIndexRenderer r =
69              new ProjectIndexRenderer( getName( locale ), project.getName(), getDescription( locale ), getSink() );
70  
71          r.render();
72      }
73  
74      /** {@inheritDoc} */
75      public String getOutputName()
76      {
77          return "index";
78      }
79  
80      // ----------------------------------------------------------------------
81      // Private
82      // ----------------------------------------------------------------------
83  
84      /**
85       * Internal renderer class
86       */
87      private static class ProjectIndexRenderer
88          extends AbstractMavenReportRenderer
89      {
90          private final String title;
91  
92          private final String description;
93  
94          private final String name;
95  
96          ProjectIndexRenderer( String title, String name, String description, Sink sink )
97          {
98              super( sink );
99  
100             this.title = title;
101 
102             this.description = description;
103 
104             this.name = name;
105         }
106 
107         /** {@inheritDoc} */
108         public String getTitle()
109         {
110             return title;
111         }
112 
113         /** {@inheritDoc} */
114         public void renderBody()
115         {
116             startSection( title.trim() + " " + name );
117 
118             paragraph( description );
119 
120             endSection();
121         }
122     }
123 }