1 16 17 package org.apache.axis.encoding.ser; 18 19 import org.apache.axis.Constants; 20 import org.apache.axis.MessageContext; 21 import org.apache.axis.encoding.SerializationContext; 22 import org.apache.axis.encoding.Serializer; 23 import org.apache.axis.utils.Messages; 24 import org.apache.axis.wsdl.fromJava.Types; 25 import org.w3c.dom.Element ; 26 import org.xml.sax.Attributes ; 27 28 import javax.xml.namespace.QName ; 29 import java.io.IOException ; 30 31 37 38 public class ElementSerializer implements Serializer { 39 42 public void serialize(QName name, Attributes attributes, 43 Object value, SerializationContext context) 44 throws IOException 45 { 46 if (!(value instanceof Element )) 47 throw new IOException (Messages.getMessage("cantSerialize01")); 48 49 MessageContext mc = context.getMessageContext(); 50 context.setWriteXMLType(null); 51 boolean writeWrapper = (mc == null) || 52 mc.isPropertyTrue("writeWrapperForElements", true); 53 if (writeWrapper) 54 context.startElement(name, attributes); 55 context.writeDOMElement((Element )value); 56 if (writeWrapper) 57 context.endElement(); 58 } 59 60 public String getMechanismType() { return Constants.AXIS_SAX; } 61 62 73 public Element writeSchema(Class javaType, Types types) throws Exception { 74 return null; 75 } 76 } 77 | Popular Tags |