1 55 56 package org.jboss.axis.encoding.ser; 57 58 import org.jboss.axis.attachments.OctetStream; 59 import org.jboss.axis.encoding.DeserializationContext; 60 import org.jboss.logging.Logger; 61 import org.xml.sax.Attributes ; 62 import org.xml.sax.SAXException ; 63 64 import javax.activation.DataHandler ; 65 import java.io.ByteArrayOutputStream ; 66 import java.io.IOException ; 67 import java.io.InputStream ; 68 69 73 public class OctetStreamDataHandlerDeserializer extends JAFDataHandlerDeserializer 74 { 75 private static Logger log = Logger.getLogger(OctetStreamDataHandlerDeserializer.class.getName()); 76 77 public void startElement(String namespace, String localName, 78 String prefix, Attributes attributes, 79 DeserializationContext context) 80 throws SAXException 81 { 82 83 super.startElement(namespace, localName, prefix, attributes, context); 84 85 if (getValue() instanceof DataHandler ) 86 { 87 try 88 { 89 DataHandler dh = (DataHandler )getValue(); 90 InputStream in = dh.getInputStream(); 91 ByteArrayOutputStream baos = new ByteArrayOutputStream (); 92 int byte1 = -1; 93 while ((byte1 = in.read()) != -1) 94 baos.write(byte1); 95 OctetStream os = new OctetStream(baos.toByteArray()); 96 setValue(os); 97 } 98 catch (IOException ioe) 99 { 100 } 101 } 102 } } | Popular Tags |