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 940323 2010-05-02 22:07:05Z hboutemy $
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 getI18nString( locale, "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              return getI18nString( locale, "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      protected String getI18Nsection()
81      {
82          return "index";
83      }
84  
85      // ----------------------------------------------------------------------
86      // Private
87      // ----------------------------------------------------------------------
88  
89      /**
90       * Internal renderer class
91       */
92      private static class ProjectIndexRenderer
93          extends AbstractMavenReportRenderer
94      {
95          private final String title;
96  
97          private final String description;
98  
99          private final String name;
100 
101         ProjectIndexRenderer( String title, String name, String description, Sink sink )
102         {
103             super( sink );
104 
105             this.title = title;
106 
107             this.description = description;
108 
109             this.name = name;
110         }
111 
112         /** {@inheritDoc} */
113         public String getTitle()
114         {
115             return title;
116         }
117 
118         /** {@inheritDoc} */
119         public void renderBody()
120         {
121             startSection( title.trim() + " " + name );
122 
123             paragraph( description );
124 
125             endSection();
126         }
127     }
128 }