1 23 24 package com.sun.enterprise.admin.servermgmt; 25 26 import com.sun.enterprise.util.i18n.StringManager; 27 28 32 public class Validator 33 { 34 37 private static final StringManager strMgr = 38 StringManager.getManager(Validator.class); 39 40 43 private final Class type; 44 45 48 private final String name; 49 50 56 public Validator(String name, Class type) 57 { 58 this.name = (name != null) ? name : ""; 59 this.type = (type != null) ? type : java.lang.Object .class; 60 } 61 62 65 public String getName() 66 { 67 return name; 68 } 69 70 76 public void validate(Object obj) throws InvalidConfigException 77 { 78 if (obj == null) 79 { 80 throw new InvalidConfigException( 81 strMgr.getString("validator.invalid_value", getName(), null)); 82 } 83 Class c = obj.getClass(); 84 if (!type.isAssignableFrom(c)) 85 { 86 throw new InvalidConfigException( 87 strMgr.getString("validator.invalid_type", 88 getName(), type.getName(), c.getName())); 89 } 90 } 91 } 92 | Popular Tags |