1 16 17 package org.apache.axis.encoding.ser; 18 19 import org.apache.axis.components.image.ImageIOFactory; 20 import org.apache.axis.components.logger.LogFactory; 21 import org.apache.axis.encoding.DeserializationContext; 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.awt.*; 28 import java.io.InputStream ; 29 30 34 public class ImageDataHandlerDeserializer extends JAFDataHandlerDeserializer { 35 protected static Log log = 36 LogFactory.getLog(ImageDataHandlerDeserializer.class.getName()); 37 38 public void startElement(String namespace, String localName, 39 String prefix, Attributes attributes, 40 DeserializationContext context) 41 throws SAXException { 42 43 super.startElement(namespace, localName, prefix, attributes, context); 44 45 if (getValue() instanceof DataHandler ) { 46 try { 47 DataHandler dh = (DataHandler ) getValue(); 48 49 InputStream is = dh.getInputStream(); 50 Image image = ImageIOFactory.getImageIO().loadImage(is); 51 setValue(image); 52 } 53 catch (Exception e) { 54 } 55 } 56 } } | Popular Tags |