1 package org.apache.maven.plugin.checkstyle;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 import java.util.ResourceBundle;
23
24 import org.apache.maven.doxia.sink.Sink;
25
26
27
28
29
30
31 public class IconTool
32 {
33 public static final String INFO = "info";
34
35 public static final String WARNING = "warning";
36
37 public static final String ERROR = "error";
38
39 public static final int NO_TEXT = 0;
40 public static final int TEXT_SIMPLE = 1;
41 public static final int TEXT_TITLE = 2;
42 public static final int TEXT_ABBREV = 3;
43
44 private final Sink sink;
45
46 private final ResourceBundle bundle;
47
48 public IconTool( Sink sink, ResourceBundle bundle )
49 {
50 this.sink = sink;
51 this.bundle = bundle;
52 }
53
54
55
56
57
58 public void iconSeverity( String level )
59 {
60 sink.figure();
61 sink.figureGraphics( "images/icon_" + level + "_sml.gif" );
62 sink.figure_();
63 }
64
65
66
67
68
69
70
71 public void iconSeverity( String level, int textType )
72 {
73 sink.figure();
74 sink.figureGraphics( "images/icon_" + level + "_sml.gif" );
75 sink.figure_();
76
77 if ( textType > 0 )
78 {
79 sink.nonBreakingSpace();
80
81 sink.text( bundle.getString( "report.checkstyle." + level + suffix( textType ) ) );
82 }
83 }
84
85
86
87
88 public void iconInfo()
89 {
90 iconSeverity( INFO );
91 }
92
93
94
95
96
97
98 public void iconInfo( int textType )
99 {
100 iconSeverity( INFO, textType );
101 }
102
103
104
105
106 public void iconWarning()
107 {
108 iconSeverity( WARNING );
109 }
110
111
112
113
114
115
116 public void iconWarning( int textType )
117 {
118 iconSeverity( WARNING, textType );
119 }
120
121
122
123
124 public void iconError()
125 {
126 iconSeverity( ERROR );
127 }
128
129
130
131
132
133
134 public void iconError( int textType )
135 {
136 iconSeverity( ERROR, textType );
137 }
138
139 private String suffix( int textType )
140 {
141 switch ( textType )
142 {
143 case TEXT_TITLE:
144 return "s";
145 case TEXT_ABBREV:
146 return "s.abbrev";
147 default:
148 return "";
149 }
150 }
151 }