1 package net.sourceforge.pmd; 2 3 import java.util.HashMap ; 4 import java.util.Map ; 5 6 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 31 public static Language getByName(String name) { 32 return (Language) mapNameOnRuleLanguage.get(name); 33 } 34 35 private String name; 36 37 42 private Language(String name) { 43 this.name = name; 44 mapNameOnRuleLanguage.put(name, this); 45 } 46 47 50 public String getName() { 51 return name; 52 } 53 54 59 public boolean equals(Object obj) { 60 if (obj instanceof Language) { 61 return ((Language) obj).getName().equals(name); 62 } else { 63 return false; 64 } 65 } 66 67 72 public int hashCode() { 73 return name.hashCode(); 74 } 75 76 79 public String toString() { 80 return "Language [" + name + "]"; 81 } 82 } 83 | Popular Tags |