Clover coverage report - PMD - 3.9 Coverage timestamp: Tue Dec 19 2006 09:38:44 EST 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 | 448 | private Language(String name) {
43 | 448 | this.name = name;
44 | 448 | mapNameOnRuleLanguage.put(name, this);
45 |  | }
46 |  |
47 |  | /**
48 |  | * @return Returns the name.
49 |  | */
50 | 3845 | public String getName() {
51 | 3845 | return name;
52 |  | }
53 |  |
54 |  | /*
55 |  | * (non-Javadoc)
56 |  | *
57 |  | * @see java.lang.Object#equals(java.lang.Object)
58 |  | */
59 | 8315 | public boolean equals(Object obj) {
60 | 8315 | if (obj instanceof Language) {
61 | 3845 | return ((Language) obj).getName().equals(name);
62 |  | } else {
63 | 4470 | 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 |  | }