1 7 package com.inversoft.util.typevalidator; 8 9 10 import java.util.HashMap ; 11 import java.util.Map ; 12 13 14 26 public class TypeValidatorRegistry { 27 28 31 private static final Map validators = new HashMap (); 32 33 36 public static final String NUMBER_VALIDATOR = "number"; 37 38 41 public static final String STRING_VALIDATOR = "string"; 42 43 46 public static final String PHONE_VALIDATOR = "phone"; 47 48 51 public static final String ZIPCODE_VALIDATOR = "zipcode"; 52 53 56 public static final String EMAIL_VALIDATOR = "email"; 57 58 61 public static final String REQUIRED_VALIDATOR = "required"; 62 63 static { 64 validators.put(NUMBER_VALIDATOR, new NumberTypeValidator()); 65 validators.put(STRING_VALIDATOR, new StringTypeValidator()); 66 validators.put(PHONE_VALIDATOR, new PhoneTypeValidator()); 67 validators.put(ZIPCODE_VALIDATOR, new ZipcodeTypeValidator()); 68 validators.put(EMAIL_VALIDATOR, new EmailTypeValidator()); 69 validators.put(REQUIRED_VALIDATOR, new RequiredTypeValidator()); 70 } 71 72 75 private TypeValidatorRegistry() { 76 } 77 78 79 85 public static void storeTypeValidator(String name, TypeValidator validator) { 86 validators.put(name, validator); 87 } 88 89 96 public static TypeValidator lookupTypeValidator(String name) { 97 return (TypeValidator) validators.get(name); 98 } 99 } | Popular Tags |