1 29 30 package com.caucho.jaxb.skeleton; 31 import javax.xml.bind.DatatypeConverter; 32 import javax.xml.bind.JAXBException; 33 import javax.xml.bind.Marshaller; 34 import javax.xml.namespace.QName ; 35 import javax.xml.stream.XMLStreamException; 36 import javax.xml.stream.XMLStreamWriter; 37 import java.io.IOException ; 38 39 42 public class FloatProperty extends CDataProperty { 43 public static final FloatProperty OBJECT_PROPERTY 44 = new FloatProperty(true); 45 public static final FloatProperty PRIMITIVE_PROPERTY 46 = new FloatProperty(false); 47 48 protected FloatProperty(boolean isNillable) 49 { 50 _isNillable = isNillable; 51 } 52 53 protected String write(Object in) 54 throws IOException , XMLStreamException 55 { 56 return DatatypeConverter.printFloat(((Number ) in).floatValue()); 57 } 58 59 protected Object read(String in) 60 throws IOException , XMLStreamException 61 { 62 return DatatypeConverter.parseFloat(in); 63 } 64 65 public String getSchemaType() 66 { 67 return "xsd:float"; 68 } 69 70 public void write(Marshaller m, XMLStreamWriter out, float f, QName qname) 71 throws IOException , XMLStreamException, JAXBException 72 { 73 writeQNameStartElement(out, qname); 74 out.writeCharacters(DatatypeConverter.printFloat(f)); 75 writeQNameEndElement(out, qname); 76 } 77 } 78 | Popular Tags |