1 16 17 package org.apache.axis.encoding.ser.castor; 18 19 import org.apache.axis.encoding.DeserializationContext; 20 import org.apache.axis.encoding.Deserializer; 21 import org.apache.axis.encoding.DeserializerImpl; 22 import org.apache.axis.message.MessageElement; 23 import org.apache.axis.utils.Messages; 24 import org.exolab.castor.xml.MarshalException; 25 import org.exolab.castor.xml.Unmarshaller; 26 import org.exolab.castor.xml.ValidationException; 27 import org.xml.sax.SAXException ; 28 29 import javax.xml.namespace.QName ; 30 31 38 public class CastorDeserializer 39 extends DeserializerImpl 40 implements Deserializer { 41 42 public QName xmlType; 43 public Class javaType; 44 45 public CastorDeserializer(Class javaType, QName xmlType) { 46 this.xmlType = xmlType; 47 this.javaType = javaType; 48 } 49 50 53 public void onEndElement( 54 String namespace, 55 String localName, 56 DeserializationContext context) 57 throws SAXException { 58 try { 59 MessageElement msgElem = context.getCurElement(); 60 if (msgElem != null) { 61 value = Unmarshaller.unmarshal(javaType, msgElem.getAsDOM()); 63 } 64 } catch (MarshalException me) { 65 log.error(Messages.getMessage("castorMarshalException00"), me); 66 throw new SAXException (Messages.getMessage("castorMarshalException00") 67 + me.getLocalizedMessage()); 68 } catch (ValidationException ve) { 69 log.error(Messages.getMessage("castorValidationException00"), ve); 70 throw new SAXException (Messages.getMessage("castorValidationException00") 71 + ve.getLocation() + ": " + ve.getLocalizedMessage()); 72 } catch (Exception exp) { 73 log.error(Messages.getMessage("exception00"), exp); 74 throw new SAXException (exp); 75 } 76 77 } 78 } 79 | Popular Tags |