1 17 18 package org.sape.carbon.core.config.type.handlers; 19 20 21 import org.sape.carbon.core.config.type.ConfigurationTypeHandler; 22 import org.sape.carbon.core.config.type.TypeConversionException; 23 24 32 public class FloatTypeHandler implements ConfigurationTypeHandler { 33 34 43 public Object toObject(Class type, String stringValue) 44 throws TypeConversionException { 45 46 Float object = null; 47 try { 48 object = Float.valueOf(stringValue); 49 } catch (NumberFormatException nfe) { 50 throw new TypeConversionException( 51 this.getClass(), 52 "Couldn't format", nfe); 53 } catch (NullPointerException npe) { 54 throw new TypeConversionException( 55 this.getClass(), 56 "Couldn't format", npe); 57 } 58 return object; 59 } 60 61 68 public String toString(Object objectValue) { 69 return ((Float ) objectValue).toString(); 70 } 71 72 } 73 | Popular Tags |