Coverage Report - org.apache.maven.reporting.AbstractMavenMultiPageReport
 
Classes in this File Line Coverage Branch Coverage Complexity
AbstractMavenMultiPageReport
0 %
0/28
0 %
0/10
1,625
 
 1  
 package org.apache.maven.reporting;
 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.siterenderer.RendererException;
 24  
 import org.apache.maven.reporting.sink.MultiPageSink;
 25  
 import org.apache.maven.reporting.sink.SinkFactory;
 26  
 
 27  
 import java.io.IOException;
 28  
 import java.util.ArrayList;
 29  
 import java.util.Iterator;
 30  
 import java.util.List;
 31  
 
 32  
 /**
 33  
  * @author <a href="evenisse@apache.org">Emmanuel Venisse</a>
 34  
  * @version $Id: MavenReport.java 163376 2005-02-23 00:06:06Z brett $
 35  
  */
 36  0
 public abstract class AbstractMavenMultiPageReport
 37  
     extends AbstractMavenReport
 38  
 {
 39  
     private SinkFactory factory;
 40  
 
 41  0
     private List sinks = new ArrayList();
 42  
 
 43  
     public void setSinkFactory( SinkFactory factory )
 44  
     {
 45  0
         this.factory = factory;
 46  0
     }
 47  
 
 48  
     public SinkFactory getSinkFactory()
 49  
     {
 50  0
         return factory;
 51  
     }
 52  
 
 53  
     public boolean useDefaultSiteDescriptor()
 54  
     {
 55  0
         return true;
 56  
     }
 57  
 
 58  
     public abstract boolean usePageLinkBar();
 59  
 
 60  
     private Sink getSink( String outputName )
 61  
         throws RendererException, IOException
 62  
     {
 63  0
         return factory.getSink( outputName );
 64  
     }
 65  
 
 66  
     public MultiPageSink startPage( String outputName )
 67  
         throws RendererException, IOException
 68  
     {
 69  0
         return new MultiPageSink( outputName, getSink( outputName ) );
 70  
     }
 71  
 
 72  
     public void endPage( MultiPageSink sink )
 73  
     {
 74  0
         if ( usePageLinkBar() )
 75  
         {
 76  0
             sinks.add( sink );
 77  
         }
 78  
         else
 79  
         {
 80  0
             sink.closeSink();
 81  
         }
 82  0
     }
 83  
 
 84  
     protected void closeReport()
 85  
     {
 86  0
         if ( !sinks.isEmpty() )
 87  
         {
 88  0
             for ( Iterator i = sinks.iterator(); i.hasNext(); )
 89  
             {
 90  0
                 MultiPageSink currentSink = (MultiPageSink) i.next();
 91  
 
 92  0
                 currentSink.paragraph();
 93  
 
 94  0
                 for ( int counter = 1; counter <= sinks.size(); counter++ )
 95  
                 {
 96  0
                     if ( counter > 1 )
 97  
                     {
 98  0
                         currentSink.text( "&nbsp;" );
 99  
                     }
 100  0
                     MultiPageSink sink = (MultiPageSink) sinks.get( counter - 1 );
 101  0
                     sink.link( sink.getOutputName() + ".html" );
 102  0
                     sink.text( String.valueOf( counter ) );
 103  0
                     sink.link_();
 104  
                 }
 105  0
                 currentSink.paragraph_();
 106  0
                 currentSink.closeSink();
 107  0
             }
 108  
         }
 109  
 
 110  0
         super.closeReport();
 111  0
     }
 112  
 }