1 55 56 package org.jboss.axis.encoding.ser; 57 58 import org.jboss.axis.encoding.DeserializationContext; 59 import org.jboss.logging.Logger; 60 import org.xml.sax.Attributes ; 61 import org.xml.sax.SAXException ; 62 63 import javax.activation.DataHandler ; 64 import javax.xml.transform.stream.StreamSource ; 65 import java.io.IOException ; 66 import java.io.StringReader ; 67 68 72 public class SourceDataHandlerDeserializer extends JAFDataHandlerDeserializer 73 { 74 private static Logger log = Logger.getLogger(SourceDataHandlerDeserializer.class.getName()); 75 76 public void startElement(String namespace, String localName, 77 String prefix, Attributes attributes, 78 DeserializationContext context) 79 throws SAXException 80 { 81 82 super.startElement(namespace, localName, prefix, attributes, context); 83 84 if (getValue() instanceof DataHandler ) 85 { 86 try 87 { 88 DataHandler dh = (DataHandler )getValue(); 89 Object content = dh.getContent(); 90 StreamSource ss = null; 91 if (content instanceof StreamSource ) 92 { 93 ss = (StreamSource )content; 94 } 95 else if (content instanceof String ) 96 { 97 ss = new StreamSource (new StringReader ((String )content)); 98 } 99 else 100 { 101 log.warn("Unknown content type [" + content.getClass() + "]"); 103 } 104 setValue(ss); 105 } 106 catch (IOException ioe) 107 { 108 } 109 } 110 } } | Popular Tags |