1 9 10 package org.jboss.util.coerce; 11 12 import org.jboss.util.CoercionException; 13 import org.jboss.util.NotCoercibleException; 14 15 21 public class ClassHandler 22 extends BoundCoercionHandler 23 { 24 29 public Class getType() { 30 return Class .class; 31 } 32 33 45 public Object coerce(Object value, Class type) throws CoercionException { 46 if (value.getClass().equals(String .class)) { 47 return coerce((String )value); 48 } 49 50 throw new NotCoercibleException(value); 51 } 52 53 62 public Object coerce(String value) { 63 try { 64 return Class.forName(value); 65 } 66 catch (ClassNotFoundException e) { 67 throw new NotCoercibleException(value, e); 68 } 69 } 70 } 71 72 | Popular Tags |