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 25 33 public class DoubleTypeHandler implements ConfigurationTypeHandler { 34 35 44 public Object toObject(Class type, String stringValue) 45 throws TypeConversionException { 46 47 Double object = null; 48 try { 49 object = Double.valueOf(stringValue); 50 } catch (NumberFormatException nfe) { 51 throw new TypeConversionException( 52 this.getClass(), 53 "Couldn't format", nfe); 54 } catch (NullPointerException npe) { 55 throw new TypeConversionException( 56 this.getClass(), 57 "Couldn't format", npe); 58 } 59 return object; 60 } 61 62 69 public String toString(Object objectValue) { 70 return ((Double ) objectValue).toString(); 71 } 72 73 } 74 | Popular Tags |