1 29 30 package com.caucho.jaxb.skeleton; 31 32 import java.io.IOException ; 33 34 import javax.xml.XMLConstants ; 35 36 import javax.xml.bind.JAXBException; 37 import javax.xml.bind.Marshaller; 38 import javax.xml.bind.Unmarshaller; 39 import javax.xml.bind.annotation.XmlAttribute; 40 import javax.xml.bind.annotation.XmlElement; 41 import javax.xml.bind.annotation.XmlElementWrapper; 42 43 import javax.xml.namespace.QName ; 44 45 import javax.xml.stream.XMLStreamException; 46 import javax.xml.stream.XMLStreamReader; 47 import javax.xml.stream.XMLStreamWriter; 48 49 52 public abstract class Property { 53 public boolean isXmlPrimitiveType() 54 { 55 return true; 56 } 57 58 public String getMaxOccurs() 59 { 60 return null; 61 } 62 63 public abstract String getSchemaType(); 64 65 public abstract Object read(Unmarshaller u, XMLStreamReader in, QName name) 66 throws IOException , XMLStreamException, JAXBException; 67 68 public abstract void write(Marshaller m, XMLStreamWriter out, 69 Object obj, QName name) 70 throws IOException , XMLStreamException, JAXBException; 71 72 protected void writeQNameStartElement(XMLStreamWriter out, QName name) 73 throws IOException , XMLStreamException 74 { 75 if (name == null) 76 return; 77 78 if (name.getPrefix() != null && ! "".equals(name.getPrefix())) { 79 out.writeStartElement(name.getPrefix(), 80 name.getLocalPart(), 81 name.getNamespaceURI()); 82 } 83 else if (name.getNamespaceURI() != null && 84 ! "".equals(name.getNamespaceURI())) { 85 out.writeStartElement(name.getNamespaceURI(), name.getLocalPart()); 86 } 87 else 88 out.writeStartElement(name.getLocalPart()); 89 } 90 91 protected void writeQNameEndElement(XMLStreamWriter out, QName name) 92 throws IOException , XMLStreamException 93 { 94 if (name == null) 95 return; 96 97 out.writeEndElement(); 98 } 99 } 100 | Popular Tags |