Coverage Report - org.apache.maven.report.projectinfo.AbstractProjectInfoRenderer
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractProjectInfoRenderer
92 %
13/14
75 %
3/4
1,333
 
 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 java.util.Locale;
 23  
 import java.util.regex.Pattern;
 24  
 
 25  
 import org.apache.maven.doxia.sink.Sink;
 26  
 import org.apache.maven.reporting.AbstractMavenReportRenderer;
 27  
 import org.codehaus.plexus.i18n.I18N;
 28  
 import org.codehaus.plexus.util.StringUtils;
 29  
 
 30  
 public abstract class AbstractProjectInfoRenderer
 31  
     extends AbstractMavenReportRenderer
 32  
 {
 33  
     private I18N i18n;
 34  
 
 35  
     private Locale locale;
 36  
 
 37  
     public AbstractProjectInfoRenderer( Sink sink, I18N i18n, Locale locale )
 38  
     {
 39  15
         super( sink );
 40  
 
 41  15
         this.i18n = i18n;
 42  
 
 43  15
         this.locale = locale;
 44  15
     }
 45  
 
 46  
     @Override
 47  
     public String getTitle()
 48  
     {
 49  23
         return getI18nString( "title" );
 50  
     }
 51  
 
 52  
     protected String getI18nString( String key )
 53  
     {
 54  96
         return getI18nString( getI18Nsection(), key );
 55  
     }
 56  
 
 57  
     protected String getI18nString( String section, String key )
 58  
     {
 59  99
         return i18n.getString( "project-info-report", locale, "report." + section + '.' + key );
 60  
     }
 61  
 
 62  
     @Override
 63  
     protected void text( String text )
 64  
     {
 65  144
         if ( StringUtils.isEmpty( text ) ) // Take care of spaces
 66  
         {
 67  6
             sink.text( "-" );
 68  
         }
 69  
         else
 70  
         {
 71  
             // custombundle text with xml?
 72  138
             String regex = "(.+?)<(\"[^\"]*\"|'[^']*'|[^'\">])*>(.+?)";
 73  138
             if ( Pattern.matches( regex, text ) )
 74  
             {
 75  0
                 sink.rawText( text );
 76  
             }
 77  
             else
 78  
             {
 79  138
                 sink.text( text );
 80  
             }
 81  
         }
 82  144
     }
 83  
 
 84  
     protected abstract String getI18Nsection();
 85  
 }