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

file stats: | LOC: | 82 |  | Methods: | 6
| NCLOC: | 34 |  | Classes: | 1

Source file | Conditionals | Statements | Methods | TOTAL
Language.java | 100% | 77.8% | 66.7% | 76.5% |

1 |  | package net.sourceforge.pmd;
2 |  |
3 |  | import java.util.HashMap;
4 |  | import java.util.Map;
5 |  |
6 |  | /**
7 |  | * Enumeration of languages for which a rule can be written.
8 |  | * <p/>
9 |  | * This has no 1-on-1 mapping to the SourceType enumeration, because rules will often
10 |  | * apply to all versions of a programming language, and SourceType is version-specific.
11 |  | *
12 |  | * @author pieter_van_raemdonck - Application Engineers NV/SA - www.ae.be
13 |  | */
14 |  | public final class Language {
15 |  | private static Map mapNameOnRuleLanguage = new HashMap();
16 |  |
17 |  | private static final String JSP_RULE_LANGUAGE_NAME = "jsp";
18 |  | private static final String JAVA_RULE_LANGUAGE_NAME = "java";
19 |  |
20 |  | public static Language JAVA = new Language(JAVA_RULE_LANGUAGE_NAME);
21 |  | public static Language JSP = new Language(JSP_RULE_LANGUAGE_NAME);
22 |  |
23 |  |
24 |  | /**
25 |  | * Get the RuleLanguage that corresponds to the given name.
26 |  | *
27 |  | * @param name the common name of the rule language; this must correspond to one of
28 |  | * the name constants.
29 |  | * @return the corresponding RuleLanuage; or null if the name is not recognized
30 |  | */
31 | 251 | public static Language getByName(String name) {
32 | 251 | return (Language) mapNameOnRuleLanguage.get(name);
33 |  | }
34 |  |
35 |  | private String name;
36 |  |
37 |  | /**
38 |  | * Public constructor.
39 |  | *
40 |  | * @param name the common name of the rule language
41 |  | */
42 | 400 | private Language(String name) {
43 | 400 | this.name = name;
44 | 400 | mapNameOnRuleLanguage.put(name, this);
45 |  | }
46 |  |
47 |  | /**
48 |  | * @return Returns the name.
49 |  | */
50 | 2110 | public String getName() {
51 | 2110 | return name;
52 |  | }
53 |  |
54 |  | /*
55 |  | * (non-Javadoc)
56 |  | *
57 |  | * @see java.lang.Object#equals(java.lang.Object)
58 |  | */
59 | 2116 | public boolean equals(Object obj) {
60 | 2116 | if (obj instanceof Language) {
61 | 2110 | return ((Language) obj).getName().equals(name);
62 |  | } else {
63 | 6 | return false;
64 |  | }
65 |  | }
66 |  |
67 |  | /*
68 |  | * (non-Javadoc)
69 |  | *
70 |  | * @see java.lang.Object#hashCode()
71 |  | */
72 | 0 | public int hashCode() {
73 | 0 | return name.hashCode();
74 |  | }
75 |  |
76 |  | /* (non-Javadoc)
77 |  | * @see java.lang.Object#toString()
78 |  | */
79 | 0 | public String toString() {
80 | 0 | return "Language [" + name + "]";
81 |  | }
82 |  | }