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