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 CharacterHandler 22 extends BoundCoercionHandler 23 { 24 29 public Class getType() { 30 return Character .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 60 public Object coerce(String value) { 61 char[] temp = value.toCharArray(); 62 if (temp.length == 0) { 63 return null; 64 } 65 return new Character (temp[0]); 66 } 67 } 68 69 | Popular Tags |