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