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