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.xml.sax.SAXException ; 25 26 import javax.xml.namespace.QName ; 27 import java.lang.reflect.Method ; 28 29 35 public class CastorEnumTypeDeserializer 36 extends DeserializerImpl 37 implements Deserializer { 38 39 public QName xmlType; 40 public Class javaType; 41 42 public CastorEnumTypeDeserializer(Class javaType, QName xmlType) { 43 this.xmlType = xmlType; 44 this.javaType = javaType; 45 } 46 47 public void onEndElement( 48 String namespace, 49 String localName, 50 DeserializationContext context) 51 throws SAXException { 52 53 try { 54 MessageElement msgElem = context.getCurElement(); 55 if (msgElem != null) { 56 Method method = javaType.getMethod("valueOf", new Class []{String .class}); 57 value = method.invoke(null, new Object []{msgElem.getValue()}); 58 } 59 } catch (Exception exp) { 60 log.error(Messages.getMessage("exception00"), exp); 61 throw new SAXException (exp); 62 } 63 64 } 65 } 66 | Popular Tags |