1 package org.apache.maven.reporting; 2 3 18 19 import org.apache.maven.doxia.sink.Sink; 20 import org.apache.maven.doxia.siterenderer.RendererException; 21 import org.apache.maven.reporting.sink.MultiPageSink; 22 import org.apache.maven.reporting.sink.SinkFactory; 23 24 import java.io.IOException ; 25 import java.util.ArrayList ; 26 import java.util.Iterator ; 27 import java.util.List ; 28 29 33 public abstract class AbstractMavenMultiPageReport 34 extends AbstractMavenReport 35 { 36 private SinkFactory factory; 37 38 private List sinks = new ArrayList (); 39 40 public void setSinkFactory( SinkFactory factory ) 41 { 42 this.factory = factory; 43 } 44 45 public SinkFactory getSinkFactory() 46 { 47 return factory; 48 } 49 50 public boolean useDefaultSiteDescriptor() 51 { 52 return true; 53 } 54 55 public abstract boolean usePageLinkBar(); 56 57 private Sink getSink( String outputName ) 58 throws RendererException, IOException 59 { 60 return factory.getSink( outputName ); 61 } 62 63 public MultiPageSink startPage( String outputName ) 64 throws RendererException, IOException 65 { 66 return new MultiPageSink( outputName, getSink( outputName ) ); 67 } 68 69 public void endPage( MultiPageSink sink ) 70 { 71 if ( usePageLinkBar() ) 72 { 73 sinks.add( sink ); 74 } 75 else 76 { 77 sink.closeSink(); 78 } 79 } 80 81 protected void closeReport() 82 { 83 if ( !sinks.isEmpty() ) 84 { 85 for ( Iterator i = sinks.iterator(); i.hasNext(); ) 86 { 87 MultiPageSink currentSink = (MultiPageSink) i.next(); 88 89 currentSink.paragraph(); 90 91 for ( int counter = 1; counter <= sinks.size(); counter++ ) 92 { 93 if ( counter > 1 ) 94 { 95 currentSink.text( " " ); 96 } 97 MultiPageSink sink = (MultiPageSink) sinks.get( counter - 1 ); 98 sink.link( sink.getOutputName() + ".html" ); 99 sink.text( String.valueOf( counter ) ); 100 sink.link_(); 101 } 102 currentSink.paragraph_(); 103 currentSink.closeSink(); 104 } 105 } 106 107 super.closeReport(); 108 } 109 } 110 | Popular Tags |