Coverage Report - org.apache.maven.report.projectinfo.ProjectIndexPageReport
 
Classes in this File Line Coverage Branch Coverage Complexity
ProjectIndexPageReport
91%
10/11
50%
1/2
1,143
ProjectIndexPageReport$ProjectIndexRenderer
100%
10/10
N/A
1,143
 
 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  1
 public class ProjectIndexPageReport
 37  
     extends AbstractProjectInfoReport
 38  
 {
 39  
     // ----------------------------------------------------------------------
 40  
     // Public methods
 41  
     // ----------------------------------------------------------------------
 42  
 
 43  
     /** {@inheritDoc} */
 44  
     public String getName( Locale locale )
 45  
     {
 46  2
         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  1
         if ( project.getDescription() != null )
 54  
         {
 55  
             // TODO How to handle i18n?
 56  0
             desc = project.getDescription();
 57  
         }
 58  
         else
 59  
         {
 60  1
             desc = i18n.getString( "project-info-report", locale, "report.index.nodescription" );
 61  
         }
 62  1
         return desc;
 63  
     }
 64  
 
 65  
     /** {@inheritDoc} */
 66  
     public void executeReport( Locale locale )
 67  
     {
 68  1
         ProjectIndexRenderer r =
 69  
             new ProjectIndexRenderer( getName( locale ), project.getName(), getDescription( locale ), getSink() );
 70  
 
 71  1
         r.render();
 72  1
     }
 73  
 
 74  
     /** {@inheritDoc} */
 75  
     public String getOutputName()
 76  
     {
 77  3
         return "index";
 78  
     }
 79  
 
 80  
     // ----------------------------------------------------------------------
 81  
     // Private
 82  
     // ----------------------------------------------------------------------
 83  
 
 84  
     /**
 85  
      * Internal renderer class
 86  
      */
 87  1
     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  1
             super( sink );
 99  
 
 100  1
             this.title = title;
 101  
 
 102  1
             this.description = description;
 103  
 
 104  1
             this.name = name;
 105  1
         }
 106  
 
 107  
         /** {@inheritDoc} */
 108  
         public String getTitle()
 109  
         {
 110  1
             return title;
 111  
         }
 112  
 
 113  
         /** {@inheritDoc} */
 114  
         public void renderBody()
 115  
         {
 116  1
             startSection( title.trim() + " " + name );
 117  
 
 118  1
             paragraph( description );
 119  
 
 120  1
             endSection();
 121  1
         }
 122  
     }
 123  
 }