1 16 17 package org.apache.axis.encoding.ser; 18 19 import org.apache.axis.components.logger.LogFactory; 20 import org.apache.axis.encoding.DeserializationContext; 21 import org.apache.axis.attachments.OctetStream; 22 import org.apache.commons.logging.Log; 23 import org.xml.sax.Attributes ; 24 import org.xml.sax.SAXException ; 25 26 import javax.activation.DataHandler ; 27 import java.io.IOException ; 28 import java.io.InputStream ; 29 import java.io.ByteArrayOutputStream ; 30 31 35 public class OctetStreamDataHandlerDeserializer extends JAFDataHandlerDeserializer { 36 protected static Log log = 37 LogFactory.getLog(OctetStreamDataHandlerDeserializer.class.getName()); 38 39 public void startElement(String namespace, String localName, 40 String prefix, Attributes attributes, 41 DeserializationContext context) 42 throws SAXException { 43 44 super.startElement(namespace, localName, prefix, attributes, context); 45 46 if (getValue() instanceof DataHandler ) { 47 try { 48 DataHandler dh = (DataHandler ) getValue(); 49 InputStream in = dh.getInputStream(); 50 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 51 int byte1 = -1; 52 while((byte1 = in.read())!=-1) 53 baos.write(byte1); 54 OctetStream os = new OctetStream(baos.toByteArray()); 55 setValue(os); 56 } catch (IOException ioe) { 57 } 58 } 59 } } | Popular Tags |