1 19 24 25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.data; 26 27 import java.io.InputStream ; 28 29 import java.util.Iterator ; 30 import java.util.Map ; 31 import java.util.HashMap ; 32 import java.util.regex.Pattern ; 33 34 import java.net.URL ; 35 import java.net.URLClassLoader ; 36 37 import org.netbeans.modules.j2ee.sun.share.configbean.Utils; 38 39 43 public class PropertyListMapping implements Comparable { 44 45 47 public static final String WEBAPP_JSPCONFIG_PROPERTIES = "WebAppJspConfigProperties"; public static final String WEBAPP_PROPERTIES = "WebAppProperties"; public static final String WEBAPP_CLASSLOADER_PROPERTIES = "WebAppClassloaderProperties"; 51 public static final String CACHE_PROPERTIES = "CacheProperties"; public static final String CACHE_DEFAULT_HELPER_PROPERTIES = "CacheDefaultHelperProperties"; public static final String CACHE_HELPER_PROPERTIES = "CacheHelperProperties"; 55 public static final String CONFIG_MANAGER_PROPERTIES = "ConfigManagerProperties"; public static final String CONFIG_STORE_PROPERTIES = "ConfigStoreProperties"; public static final String CONFIG_SESSION_PROPERTIES = "ConfigSessionProperties"; public static final String CONFIG_COOKIE_PROPERTIES = "ConfigCookieProperties"; 60 public static final String SERVICE_REF_CALL_PROPERTIES = "ServiceRefCallProperties"; public static final String SERVICE_REF_STUB_PROPERTIES = "ServiceRefStubProperties"; 63 public static final String EJBJAR_CMP_PROPERTIES = "EjbJarCmpProperties"; public static final String EJBJAR_CMP_SCHEMA_PROPERTIES = "EjbJarCmpSchemaProperties"; 66 67 private final PropertyList propList; 68 70 73 private PropertyListMapping(final PropertyList l) { 74 propList = l; 75 } 76 77 82 public boolean equals(Object obj) { 83 boolean result = false; 84 85 if(obj instanceof PropertyListMapping) { 86 if(this == obj) { 87 result = true; 88 } else { 89 PropertyListMapping targetMapping = (PropertyListMapping) obj; 90 PropertyList targetList = targetMapping.getPropertyList(); 91 result = propList.getPropertyName().equals(targetList.getPropertyName()); 92 } 93 } 94 return result; 95 } 96 97 101 public int hashCode() { 102 return propList.getPropertyName().hashCode(); 103 } 104 105 109 public String toString() { 110 return propList.getPropertyName(); 111 } 112 113 117 public PropertyList getPropertyList() { 118 return propList; 119 } 120 121 127 public int compareTo(Object obj) { 128 int result = -1; 129 130 if(obj instanceof PropertyListMapping) { 131 if(this == obj) { 132 result = 0; 133 } else { 134 PropertyListMapping targetMapping = (PropertyListMapping) obj; 135 PropertyList targetList = targetMapping.getPropertyList(); 136 result = propList.getPropertyName().compareTo(targetList.getPropertyName()); 137 } 138 } 139 140 return result; 141 } 142 143 146 152 public static PropertyList getPropertyList(String propertyListName) { 153 return (PropertyList) propertyLists.get(propertyListName); 154 } 155 156 169 public static Pattern getValidator(String validatorName) { 170 return (Pattern ) validatorList.get(validatorName); 171 } 172 173 private static final String PROPERTYDATA_FILENAME = 174 "org/netbeans/modules/j2ee/sun/share/configbean/customizers/data/propertydata.xml"; 176 private static Map propertyLists; 177 private static Map validatorList; 178 179 static { 180 loadPropertyLists(); 181 } 182 183 private static void loadPropertyLists() { 184 propertyLists = new HashMap (37); 185 validatorList = new HashMap (19); 186 187 try { 188 URL propertyListURL = Utils.getResourceURL(PROPERTYDATA_FILENAME, PropertyListMapping.class); 189 InputStream inputStream = propertyListURL.openStream(); 190 191 DynamicProperties props = DynamicProperties.read(inputStream); 192 for(Iterator iter = props.fetchPropertyListList().iterator(); iter.hasNext(); ) { 193 PropertyList propList = (PropertyList) iter.next(); 194 String propertyListName = propList.getPropertyName(); 195 propertyLists.put(propertyListName, propList); 196 } 197 198 for(Iterator iter = props.fetchValidatorList().iterator(); iter.hasNext(); ) { 199 Validator validator = (Validator) iter.next(); 200 Pattern pattern = Pattern.compile(validator.getValidatorPattern()); 201 validatorList.put(validator.getValidatorName(), pattern); 202 } 203 } catch(Exception ex) { 204 ex.printStackTrace(); 207 } 208 } 209 } 210 | Popular Tags |