1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package org.codehaus.mojo.cobertura.configuration;
21
22 import java.io.File;
23 import java.util.ArrayList;
24 import java.util.Iterator;
25 import java.util.List;
26
27
28
29
30
31
32 public class ConfigInstrumentation
33 {
34 private File basedir;
35
36 private List<String> excludes;
37
38 private List<String> ignores;
39
40 private List<String> includes;
41
42 private String maxmem;
43
44 private boolean ignoreTrivial;
45
46 private List<String> ignoreMethodAnnotations;
47
48
49
50
51 public ConfigInstrumentation()
52 {
53 this.includes = new ArrayList<String>();
54 this.excludes = new ArrayList<String>();
55 this.ignores = new ArrayList<String>();
56 this.ignoreTrivial = false;
57 this.ignoreMethodAnnotations = new ArrayList<String>();
58
59 this.basedir = new File( System.getProperty( "user.dir" ) );
60
61 if ( MaxHeapSizeUtil.getInstance().envHasMavenMaxMemSetting() )
62 {
63 maxmem = MaxHeapSizeUtil.getInstance().getMavenMaxMemSetting();
64 }
65 else
66 {
67 this.maxmem = "64m";
68 }
69 }
70
71
72
73
74
75
76 public void addExclude( String exclude )
77 {
78 this.excludes.add( exclude );
79 }
80
81
82
83
84
85
86 public void addIgnore( String ignore )
87 {
88 this.ignores.add( ignore );
89 }
90
91
92
93
94
95
96
97 public void addIgnoreMethodAnnotation( String ignoreMethodAnnotation )
98 {
99 this.ignoreMethodAnnotations.add( ignoreMethodAnnotation );
100 }
101
102
103
104
105
106
107 public void addInclude( String include )
108 {
109 this.includes.add( include );
110 }
111
112
113
114
115 public File getBasedir()
116 {
117 return basedir;
118 }
119
120
121
122
123
124
125 public List<String> getExcludes()
126 {
127 return excludes;
128 }
129
130
131
132
133
134
135 public List<String> getIgnores()
136 {
137 return ignores;
138 }
139
140
141
142
143
144
145 public List<String> getIncludes()
146 {
147 return includes;
148 }
149
150
151
152
153 public void setBasedir( File basedir )
154 {
155 this.basedir = basedir;
156 }
157
158
159
160
161
162
163 public String getMaxmem()
164 {
165 return maxmem;
166 }
167
168
169
170
171
172
173
174 public void setMaxmem( String maxmem )
175 {
176 this.maxmem = maxmem;
177 }
178
179
180
181
182
183
184 public boolean getIgnoreTrivial()
185 {
186 return ignoreTrivial;
187 }
188
189
190
191
192
193
194
195
196 public void setIgnoreTrivial( boolean ignoreTrivial )
197 {
198 this.ignoreTrivial = ignoreTrivial;
199 }
200
201
202
203
204
205
206 public List<String> getIgnoreMethodAnnotations()
207 {
208 return ignoreMethodAnnotations;
209 }
210
211
212
213
214
215
216
217 public void setIgnoreMethodAnnotations( List<String> ignoreMethodAnnotations )
218 {
219 this.ignoreMethodAnnotations = ignoreMethodAnnotations;
220 }
221
222
223
224
225
226 public String toString()
227 {
228 StringBuffer sb = new StringBuffer();
229 sb.append( "<ConfigInstrumentation" );
230
231 sb.append( " basedir=\"" );
232 if ( this.basedir != null )
233 {
234 sb.append( basedir.getAbsolutePath() );
235 }
236 sb.append( "\"" );
237
238 if ( !this.includes.isEmpty() )
239 {
240 sb.append( " includes=\"" );
241 Iterator<String> it = this.includes.iterator();
242 while ( it.hasNext() )
243 {
244 String include = (String) it.next();
245 sb.append( include );
246
247 if ( it.hasNext() )
248 {
249 sb.append( " " );
250 }
251 }
252 sb.append( "\"" );
253 }
254
255 if ( !this.excludes.isEmpty() )
256 {
257 sb.append( " excludes=\"" );
258 Iterator<String> it = this.excludes.iterator();
259 while ( it.hasNext() )
260 {
261 String exclude = (String) it.next();
262 sb.append( exclude );
263 if ( it.hasNext() )
264 {
265 sb.append( " " );
266 }
267 }
268 sb.append( "\"" );
269 }
270
271 if ( !this.ignores.isEmpty() )
272 {
273 sb.append( " ignores=\"" );
274 Iterator<String> it = this.ignores.iterator();
275 while ( it.hasNext() )
276 {
277 String ignore = (String) it.next();
278 sb.append( ignore );
279 if ( it.hasNext() )
280 {
281 sb.append( " " );
282 }
283 }
284 sb.append( "\"" );
285 }
286
287 if ( 0 != getMaxmem().length() )
288 {
289 sb.append( " maxmem=\"" );
290 sb.append( getMaxmem() );
291 sb.append( "\"" );
292 }
293
294 sb.append( " ignoreTrivial=\"" );
295 sb.append( getIgnoreTrivial() );
296 sb.append( "\"" );
297
298 if ( !this.ignoreMethodAnnotations.isEmpty() )
299 {
300 sb.append( " ignoreMethodAnnotations=\"" );
301 Iterator<String> it = this.ignoreMethodAnnotations.iterator();
302 while ( it.hasNext() )
303 {
304 String ignore = (String) it.next();
305 sb.append( ignore );
306 if ( it.hasNext() )
307 {
308 sb.append( " " );
309 }
310 }
311 sb.append( "\"" );
312 }
313
314 return sb.append( " />" ).toString();
315 }
316
317 }