1 package org.codehaus.mojo.javancss;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.text.MessageFormat;
23 import java.util.ResourceBundle;
24
25 import org.apache.maven.doxia.sink.Sink;
26 import org.apache.maven.plugin.logging.Log;
27
28
29
30
31
32
33
34
35 public abstract class AbstractNcssReportGenerator
36 {
37 private ResourceBundle bundle;
38
39 private Sink sink;
40
41 private Log log;
42
43
44
45
46
47
48
49
50 protected AbstractNcssReportGenerator( Sink sink, ResourceBundle bundle, Log log )
51 {
52 this.bundle = bundle;
53 this.sink = sink;
54 this.log = log;
55 }
56
57
58
59
60
61
62 public Log getLog()
63 {
64 return this.log;
65 }
66
67
68
69
70
71
72 public Sink getSink()
73 {
74 return this.sink;
75 }
76
77
78
79
80
81
82 public ResourceBundle getResourceBundle()
83 {
84 return this.bundle;
85 }
86
87
88
89
90
91
92 protected void codeItemListHelper( String text )
93 {
94 sink.listItem();
95 sink.monospaced();
96 sink.text( text );
97 sink.monospaced_();
98 sink.listItem_();
99 }
100
101
102
103
104
105
106 protected void paragraphHelper( String text )
107 {
108 sink.paragraph();
109 sink.text( text );
110 sink.paragraph_();
111 }
112
113
114
115
116
117
118 protected void subtitleHelper( String text )
119 {
120 sink.paragraph();
121 sink.bold();
122 sink.text( text );
123 sink.bold_();
124 sink.paragraph_();
125 }
126
127
128
129
130
131
132 protected void codeCellHelper( String text )
133 {
134 sink.tableCell();
135 sink.monospaced();
136 sink.text( text );
137 sink.monospaced_();
138 sink.tableCell_();
139 }
140
141
142
143
144
145
146 protected void headerCellHelper( String text )
147 {
148 sink.tableHeaderCell();
149 sink.text( text );
150 sink.tableHeaderCell_();
151 }
152
153
154
155
156
157
158 protected void tableCellHelper( String text )
159 {
160 sink.tableCell();
161 sink.text( text );
162 sink.tableCell_();
163 }
164
165
166
167
168
169
170
171 protected void startSection( String link, String title )
172 {
173 sink.section1();
174 sink.sectionTitle1();
175 sink.text( bundle.getString( title ) );
176 sink.sectionTitle1_();
177
178 sink.anchor( bundle.getString( link ) );
179 sink.text( bundle.getString( title ) );
180 sink.anchor_();
181 }
182
183
184
185
186 protected void endSection()
187 {
188 sink.section1_();
189 }
190
191
192
193
194
195
196
197 protected String getString( String key )
198 {
199 return bundle.getString( key );
200 }
201
202
203
204
205
206
207 protected void doIntro( boolean withNavigationBar )
208 {
209 getSink().section1();
210 getSink().sectionTitle1();
211 getSink().text( getString( "report.javancss.main.title" ) );
212 getSink().sectionTitle1_();
213 if ( withNavigationBar )
214 {
215 navigationBar();
216 }
217 getSink().paragraph();
218 String version = NcssExecuter.getJavaNCSSVersion();
219 getSink().text( MessageFormat.format( getString( "report.javancss.main.text" ), version ) );
220 getSink().lineBreak();
221 getSink().link( "http://javancss.codehaus.org/" );
222 getSink().text( "JavaNCSS web site." );
223 getSink().link_();
224 getSink().paragraph_();
225 getSink().section1_();
226 }
227
228
229 protected void navigationBar()
230 {
231 getSink().paragraph();
232 getSink().text( "[ " );
233 getSink().link( "#" + getString( "report.javancss.package.link" ) );
234 getSink().text( getString( "report.javancss.package.link" ) );
235 getSink().link_();
236 getSink().text( " ] [ " );
237 getSink().link( "#" + getString( "report.javancss.object.link" ) );
238 getSink().text( getString( "report.javancss.object.link" ) );
239 getSink().link_();
240 getSink().text( " ] [ " );
241 getSink().link( "#" + getString( "report.javancss.function.link" ) );
242 getSink().text( getString( "report.javancss.function.link" ) );
243 getSink().link_();
244 getSink().text( " ] [ " );
245 getSink().link( "#" + getString( "report.javancss.explanation.link" ) );
246 getSink().text( getString( "report.javancss.explanation.link" ) );
247 getSink().link_();
248 getSink().text( " ]" );
249 getSink().paragraph_();
250 }
251 }