Clover coverage report - PMD - 3.7 Coverage timestamp: Wed May 31 2006 09:25:59 EDT FRAMES NO FRAMES |

file stats: | LOC: | 72 |  | Methods: | 2
| NCLOC: | 61 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL
Appendix.java | 0% | 0% | 0% | 0% |

1 |  | package net.sourceforge.pmd.util;
2 |  |
3 |  | import net.sourceforge.pmd.PMD;
4 |  | import net.sourceforge.pmd.Rule;
5 |  | import net.sourceforge.pmd.RuleSet;
6 |  | import net.sourceforge.pmd.RuleSetFactory;
7 |  |
8 |  | import java.util.Collection;
9 |  | import java.util.Iterator;
10 |  | import java.util.Set;
11 |  |
12 |  | public class Appendix {
13 |  |
14 | 0 | public static void main(String[] args) throws Exception {
15 | 0 | RuleSetFactory rsf = new RuleSetFactory();
16 | 0 | Iterator i = rsf.getRegisteredRuleSets();
17 | 0 | StringBuffer sb = new StringBuffer();
18 | 0 | while (i.hasNext()) {
19 | 0 | RuleSet rs = (RuleSet) i.next();
20 | 0 | if (rs.getName().toLowerCase().indexOf(args[0]) == -1) {
21 | 0 | continue;
22 |  | }
23 | 0 | sb.append("====================================================================" + PMD.EOL);
24 | 0 | sb.append(rs.getName() + PMD.EOL);
25 | 0 | sb.append(rs.getDescription() + PMD.EOL);
26 | 0 | sb.append("--------------------------------------------------------------------" + PMD.EOL);
27 |  |
28 | 0 | Collection rules = rs.getRules();
29 | 0 | for (Iterator j = rules.iterator(); j.hasNext();) {
30 | 0 | Rule r = (Rule) j.next();
31 | 0 | sb.append(r.getName() + ": " + trimCRs(r.getDescription()) + PMD.EOL);
32 | 0 | sb.append("Example: " + PMD.EOL + trimCRs(r.getExample()) + PMD.EOL);
33 |  |
34 | 0 | if (r.hasProperty("xpath")) {
35 | 0 | sb.append("XPath expression:" + PMD.EOL);
36 | 0 | sb.append(trimCRs(r.getProperties().getProperty("xpath")));
37 |  | }
38 |  |
39 | 0 | Set keys = r.getProperties().keySet();
40 | 0 | boolean header = false;
41 | 0 | for (Iterator k = keys.iterator(); k.hasNext();) {
42 | 0 | String key = (String) k.next();
43 | 0 | String value = (String) r.getProperties().getProperty(key);
44 |  |
45 | 0 | if (key.equals("xpath")) {
46 | 0 | continue;
47 |  | }
48 |  |
49 | 0 | if (!header) {
50 | 0 | sb.append(PMD.EOL + "Properties:" + PMD.EOL);
51 | 0 | header = true;
52 |  | }
53 |  |
54 | 0 | sb.append("Name = '" + key + "', value = '" + value + "'" + PMD.EOL);
55 |  | }
56 | 0 | sb.append(PMD.EOL + "Notes: " + PMD.EOL);
57 | 0 | sb.append(PMD.EOL + "--------------------------------------------------------------------" + PMD.EOL);
58 |  | }
59 |  | }
60 | 0 | System.out.println(sb.toString());
61 |  | }
62 |  |
63 | 0 | private static String trimCRs(String str) {
64 | 0 | while (str.startsWith(PMD.EOL)) {
65 | 0 | str = str.substring(1);
66 |  | }
67 | 0 | while (str.endsWith(PMD.EOL)) {
68 | 0 | str = str.substring(0, str.length() - 1);
69 |  | }
70 | 0 | return str;
71 |  | }
72 |  | }