1 | |
package org.apache.maven.reporting; |
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
|
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 | |
|
34 | |
|
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( " " ); |
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 | |
} |