Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST FRAMES NO FRAMES |
file stats: | LOC: | 78 |  | Methods: | 5
| NCLOC: | 70 |  | Classes: | 1
Source file | Conditionals | Statements | Methods | TOTAL
SimpleRuleSetNameMapper.java | 100% | 100% | 100% | 100% |

1 |  | package net.sourceforge.pmd;
2 |  |
3 |  | import java.util.HashMap;
4 |  | import java.util.Map;
5 |  | import java.util.StringTokenizer;
6 |  |
7 |  | public class SimpleRuleSetNameMapper {
8 |  |
9 |  | private StringBuffer rulesets = new StringBuffer();
10 |  | private Map nameMap = new HashMap();
11 |  |
12 | 257 | public SimpleRuleSetNameMapper(String ruleString) {
13 | 257 | populateNameMap();
14 | 257 | if (ruleString.indexOf(',') == -1) {
15 | 253 | check(ruleString);
16 | 253 | return;
17 |  | }
18 | 4 | for (StringTokenizer st = new StringTokenizer(ruleString, ","); st.hasMoreTokens();) {
19 | 8 | String tok = st.nextToken();
20 | 8 | check(tok);
21 |  | }
22 |  | }
23 |  |
24 | 257 | public String getRuleSets() {
25 | 257 | return rulesets.toString();
26 |  | }
27 |  |
28 | 261 | private void check(String name) {
29 | 261 | if (name.indexOf("rulesets") == -1 && nameMap.containsKey(name)) {
30 | 243 | append((String) nameMap.get(name));
31 |  | } else {
32 | 18 | append(name);
33 |  | }
34 |  | }
35 |  |
36 | 261 | private void append(String name) {
37 | 261 | if (rulesets.length() > 0) {
38 | 4 | rulesets.append(',');
39 |  | }
40 | 261 | rulesets.append(name);
41 |  | }
42 |  |
43 | 257 | private void populateNameMap() {
44 | 257 | nameMap.put("basic", "rulesets/basic.xml");
45 | 257 | nameMap.put("jsp", "rulesets/basic-jsp.xml");
46 | 257 | nameMap.put("jsf", "rulesets/basic-jsf.xml");
47 | 257 | nameMap.put("braces", "rulesets/braces.xml");
48 | 257 | nameMap.put("clone", "rulesets/clone.xml");
49 | 257 | nameMap.put("codesize", "rulesets/codesize.xml");
50 | 257 | nameMap.put("controversial", "rulesets/controversial.xml");
51 | 257 | nameMap.put("coupling", "rulesets/coupling.xml");
52 | 257 | nameMap.put("design", "rulesets/design.xml");
53 | 257 | nameMap.put("finalizers", "rulesets/finalizers.xml");
54 | 257 | nameMap.put("imports", "rulesets/imports.xml");
55 | 257 | nameMap.put("j2ee", "rulesets/j2ee.xml");
56 | 257 | nameMap.put("junit", "rulesets/junit.xml");
57 | 257 | nameMap.put("javabeans", "rulesets/javabeans.xml");
58 | 257 | nameMap.put("logging-java", "rulesets/logging-java.xml");
59 | 257 | nameMap.put("logging-jakarta", "rulesets/logging-jakarta-commons.xml");
60 | 257 | nameMap.put("logging-jakarta-commons", "rulesets/logging-jakarta-commons.xml");
61 | 257 | nameMap.put("migrating", "rulesets/migrating.xml");
62 | 257 | nameMap.put("naming", "rulesets/naming.xml");
63 | 257 | nameMap.put("optimizations", "rulesets/optimizations.xml");
64 | 257 | nameMap.put("scratchpad", "rulesets/scratchpad.xml");
65 | 257 | nameMap.put("strictexception", "rulesets/strictexception.xml");
66 | 257 | nameMap.put("strings", "rulesets/strings.xml");
67 | 257 | nameMap.put("sunsecure", "rulesets/sunsecure.xml");
68 | 257 | nameMap.put("typeresolution", "rulesets/typeresolution.xml");
69 | 257 | nameMap.put("unusedcode", "rulesets/unusedcode.xml");
70 | 257 | nameMap.put("33", "rulesets/releases/33.xml");
71 | 257 | nameMap.put("34", "rulesets/releases/34.xml");
72 | 257 | nameMap.put("35", "rulesets/releases/35.xml");
73 | 257 | nameMap.put("36", "rulesets/releases/36.xml");
74 | 257 | nameMap.put("37", "rulesets/releases/37.xml");
75 | 257 | nameMap.put("38", "rulesets/releases/38.xml");
76 | 257 | nameMap.put("39", "rulesets/releases/39.xml");
77 |  | }
78 |  | }