1 16 17 package org.apache.axis.encoding.ser; 18 19 import org.apache.axis.attachments.SourceDataSource; 20 import org.apache.axis.components.logger.LogFactory; 21 import org.apache.axis.encoding.SerializationContext; 22 import org.apache.axis.utils.Messages; 23 import org.apache.commons.logging.Log; 24 import org.xml.sax.Attributes ; 25 26 import javax.activation.DataHandler ; 27 import javax.xml.namespace.QName ; 28 import javax.xml.transform.stream.StreamSource ; 29 import java.io.IOException ; 30 31 35 public class SourceDataHandlerSerializer extends JAFDataHandlerSerializer { 36 37 protected static Log log = 38 LogFactory.getLog(SourceDataHandlerSerializer.class.getName()); 39 40 43 public void serialize(QName name, Attributes attributes, 44 Object value, SerializationContext context) 45 throws IOException 46 { 47 if (value != null) { 48 if (!(value instanceof StreamSource )) { 49 throw new IOException (Messages.getMessage("badSource", 50 value.getClass().getName())); 51 } 52 DataHandler dh = new DataHandler (new SourceDataSource("source", 53 "text/xml", (StreamSource ) value)); 54 super.serialize(name, attributes, dh, context); 55 } 56 } } | Popular Tags |