1 16 17 package org.apache.axis.encoding.ser; 18 19 import org.apache.axis.Constants; 20 import org.apache.axis.encoding.SerializationContext; 21 import org.apache.axis.encoding.SimpleValueSerializer; 22 import org.apache.axis.wsdl.fromJava.Types; 23 import org.w3c.dom.Element ; 24 import org.xml.sax.Attributes ; 25 26 import javax.xml.namespace.QName ; 27 import java.io.IOException ; 28 29 32 public class QNameSerializer implements SimpleValueSerializer { 33 34 37 public void serialize(QName name, Attributes attributes, 38 Object value, SerializationContext context) 39 throws IOException 40 { 41 String qnameString = getValueAsString(value, context); 44 context.startElement(name, attributes); 45 context.writeString(qnameString); 46 context.endElement(); 47 } 48 49 public static String qName2String(QName qname, 50 SerializationContext context) { 51 String str = context.qName2String(qname); 52 if (str == qname.getLocalPart()) { 54 String namespace = qname.getNamespaceURI(); 55 if (namespace != null && namespace.length() > 0) { 56 String prefix = 57 context.getPrefixForURI(qname.getNamespaceURI(), 58 null, true); 59 return prefix + ":" + str; 60 } 61 } 62 return str; 63 } 64 65 public String getValueAsString(Object value, SerializationContext context) { 66 return qName2String((QName )value, context); 67 } 68 69 public String getMechanismType() { return Constants.AXIS_SAX; } 70 71 82 public Element writeSchema(Class javaType, Types types) throws Exception { 83 return null; 84 } 85 } 86 | Popular Tags |