1 17 package org.sape.carbon.core.config.type.handlers; 18 19 import java.net.MalformedURLException ; 20 import java.net.URL ; 21 22 import org.sape.carbon.core.config.type.ConfigurationTypeHandler; 23 import org.sape.carbon.core.config.type.TypeConversionException; 24 25 33 public class URLTypeHandler implements ConfigurationTypeHandler { 34 35 38 public String toString(Object objectValue) { 39 return objectValue.toString(); 40 } 41 42 45 public Object toObject(Class returnType, String stringValue) 46 throws TypeConversionException { 47 48 try { 49 return new URL (stringValue); 50 } catch (MalformedURLException mfurle) { 51 throw new TypeConversionException( 52 this.getClass(), 53 "could not format URL", 54 mfurle); 55 } 56 } 57 58 } 59 | Popular Tags |