Coverage Report - org.apache.maven.plugin.issues.AbstractIssuesReportGenerator
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractIssuesReportGenerator
0%
0/88
0%
0/16
1,533
 
 1  
 package org.apache.maven.plugin.issues;
 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.doxia.util.HtmlTools;
 24  
 import org.codehaus.plexus.util.StringUtils;
 25  
 
 26  
 import java.util.ResourceBundle;
 27  
 
 28  
 /**
 29  
  * An abstract super class that helps when generating a report on issues.
 30  
  *
 31  
  * @author Dennis Lundberg
 32  
  * @version $Id: org.apache.maven.plugin.issues.AbstractIssuesReportGenerator.html 816598 2012-05-08 12:46:49Z hboutemy $
 33  
  * @since 2.4
 34  
  */
 35  
 public abstract class AbstractIssuesReportGenerator
 36  
 {
 37  
     protected String author;
 38  
 
 39  
     protected String title;
 40  
 
 41  
     public AbstractIssuesReportGenerator()
 42  0
     {
 43  0
     }
 44  
 
 45  
     public String getAuthor()
 46  
     {
 47  0
         return author;
 48  
     }
 49  
 
 50  
     public void setAuthor( String author )
 51  
     {
 52  0
         this.author = author;
 53  0
     }
 54  
 
 55  
     public String getTitle()
 56  
     {
 57  0
         return title;
 58  
     }
 59  
 
 60  
     public void setTitle( String title )
 61  
     {
 62  0
         this.title = title;
 63  0
     }
 64  
 
 65  
     protected void sinkBeginReport( Sink sink, ResourceBundle bundle )
 66  
     {
 67  0
         sink.head();
 68  
 
 69  0
         String title = null;
 70  0
         if ( this.title != null )
 71  
         {
 72  0
             title = this.title;
 73  
         }
 74  
         else
 75  
         {
 76  0
             title = bundle.getString( "report.issues.header" );
 77  
         }
 78  0
         sink.title();
 79  0
         sink.text( title );
 80  0
         sink.title_();
 81  
 
 82  0
         if ( StringUtils.isNotEmpty( author ) )
 83  
         {
 84  0
             sink.author();
 85  0
             sink.text( author );
 86  0
             sink.author_();
 87  
         }
 88  
 
 89  0
         sink.head_();
 90  
 
 91  0
         sink.body();
 92  
 
 93  0
         sink.section1();
 94  
 
 95  0
         sinkSectionTitle1Anchor( sink, title, title );
 96  0
     }
 97  
 
 98  
     protected void sinkCell( Sink sink, String text )
 99  
     {
 100  0
         sink.tableCell();
 101  
 
 102  0
         if ( text != null )
 103  
         {
 104  0
             sink.text( text );
 105  
         }
 106  
         else
 107  
         {
 108  0
             sink.nonBreakingSpace();
 109  
         }
 110  
 
 111  0
         sink.tableCell_();
 112  0
     }
 113  
 
 114  
     protected void sinkCellLink( Sink sink, String text, String link )
 115  
     {
 116  0
         sink.tableCell();
 117  
 
 118  0
         sinkLink( sink, text, link );
 119  
 
 120  0
         sink.tableCell_();
 121  0
     }
 122  
 
 123  
     protected void sinkEndReport( Sink sink )
 124  
     {
 125  0
         sink.section1_();
 126  
 
 127  0
         sink.body_();
 128  
 
 129  0
         sink.flush();
 130  
 
 131  0
         sink.close();
 132  0
     }
 133  
 
 134  
     protected void sinkFigure( Sink sink, String image, String altText )
 135  
     {
 136  0
         sink.figure();
 137  
 
 138  0
         sink.figureGraphics( image );
 139  
 
 140  0
         sink.figureCaption();
 141  
 
 142  0
         sink.text( altText );
 143  
 
 144  0
         sink.figureCaption_();
 145  
 
 146  0
         sink.figure_();
 147  0
     }
 148  
 
 149  
     protected void sinkHeader( Sink sink, String header )
 150  
     {
 151  0
         sink.tableHeaderCell();
 152  
 
 153  0
         sink.text( header );
 154  
 
 155  0
         sink.tableHeaderCell_();
 156  0
     }
 157  
 
 158  
     protected void sinkLink( Sink sink, String text, String link )
 159  
     {
 160  0
         sink.link( link );
 161  
 
 162  0
         sink.text( text );
 163  
 
 164  0
         sink.link_();
 165  0
     }
 166  
 
 167  
     protected void sinkSectionTitle1Anchor( Sink sink, String text, String anchor )
 168  
     {
 169  0
         sink.sectionTitle1();
 170  
 
 171  0
         sink.text( text );
 172  
 
 173  0
         sink.sectionTitle1_();
 174  
 
 175  0
         sink.anchor( HtmlTools.encodeId( anchor ) );
 176  0
         sink.anchor_();
 177  0
     }
 178  
 
 179  
     protected void sinkSectionTitle2Anchor( Sink sink, String text, String anchor )
 180  
     {
 181  0
         sink.sectionTitle2();
 182  0
         sink.text( text );
 183  0
         sink.sectionTitle2_();
 184  
 
 185  0
         sink.anchor( HtmlTools.encodeId( anchor ) );
 186  0
         sink.anchor_();
 187  0
     }
 188  
 
 189  
     protected void sinkShowTypeIcon( Sink sink, String type )
 190  
     {
 191  0
         String image = "";
 192  0
         String altText = "";
 193  
 
 194  0
         if ( type == null )
 195  
         {
 196  0
             image = "images/icon_help_sml.gif";
 197  0
             altText = "?";
 198  
         }
 199  0
         else if ( type.equals( "fix" ) )
 200  
         {
 201  0
             image = "images/fix.gif";
 202  0
             altText = "fix";
 203  
         }
 204  0
         else if ( type.equals( "update" ) )
 205  
         {
 206  0
             image = "images/update.gif";
 207  0
             altText = "update";
 208  
         }
 209  0
         else if ( type.equals( "add" ) )
 210  
         {
 211  0
             image = "images/add.gif";
 212  0
             altText = "add";
 213  
         }
 214  0
         else if ( type.equals( "remove" ) )
 215  
         {
 216  0
             image = "images/remove.gif";
 217  0
             altText = "remove";
 218  
         }
 219  
 
 220  0
         sink.tableCell();
 221  
 
 222  0
         sinkFigure( sink, image, altText );
 223  
 
 224  0
         sink.tableCell_();
 225  0
     }
 226  
 }