1 29 30 package com.caucho.config.jaxb; 31 32 import com.caucho.config.ConfigException; 33 import com.caucho.config.NodeBuilder; 34 import com.caucho.xml.QName; 35 36 import org.w3c.dom.Node ; 37 38 import java.lang.reflect.InvocationTargetException ; 39 import java.lang.reflect.Method ; 40 41 public class FloatProperty extends JaxbProperty { 42 private final Method _method; 43 44 public FloatProperty(Method method) 45 { 46 _method = method; 47 } 48 49 57 public void configureAttribute(NodeBuilder builder, 58 Object bean, 59 QName name, 60 String value) 61 throws ConfigException 62 { 63 } 64 65 73 public void configureElement(NodeBuilder builder, 74 Object bean, 75 QName name, 76 Node node) 77 throws ConfigException 78 { 79 String textValue = node.getTextContent().trim(); 80 81 double value = builder.evalDouble(textValue); 82 83 try { 84 _method.invoke(bean, new Float ((float) value)); 85 } catch (IllegalAccessException e) { 86 throw builder.error(e, node); 87 } catch (InvocationTargetException e) { 88 throw builder.error(e.getCause(), node); 89 } 90 } 91 } 92 | Popular Tags |