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 IntProperty extends CDataProperty { 43 public static final IntProperty OBJECT_PROPERTY = new IntProperty(true); 44 public static final IntProperty PRIMITIVE_PROPERTY = new IntProperty(false); 45 46 protected IntProperty(boolean isNillable) 47 { 48 _isNillable = isNillable; 49 } 50 51 protected String write(Object in) 52 throws IOException , XMLStreamException 53 { 54 return DatatypeConverter.printInt(((Integer ) in).intValue()); 55 } 56 57 protected Object read(String in) 58 throws IOException , XMLStreamException 59 { 60 return DatatypeConverter.parseInt(in); 61 } 62 63 public String getSchemaType() 64 { 65 return "xsd:int"; 66 } 67 68 public void write(Marshaller m, XMLStreamWriter out, int i, QName qname) 69 throws IOException , XMLStreamException, JAXBException 70 { 71 writeQNameStartElement(out, qname); 72 out.writeCharacters(DatatypeConverter.printInt(i)); 73 writeQNameEndElement(out, qname); 74 } 75 } 76 77 78 | Popular Tags |