1 package org.sapia.validator.config; 2 3 4 14 public class Def { 15 private String _name; 16 private String _class; 17 18 public void setName(String name) { 19 _name = name; 20 } 21 22 public String getName() { 23 return _name; 24 } 25 26 public void setClass(String clazz) { 27 _class = clazz; 28 } 29 30 public Object toInstance() throws ConfigException { 31 if (_name == null) { 32 throw new ConfigException("'name' attribute not specified for definition"); 33 } 34 35 if (_class == null) { 36 throw new ConfigException( 37 "'class' attribute not specified for definition " + _name); 38 } 39 40 try { 41 return Class.forName(_class).newInstance(); 42 } catch (Throwable t) { 43 throw new ConfigException("Could not instantiate definition " + _name, t); 44 } 45 } 46 } 47 | Popular Tags |