1 7 8 10 package org.jboss.net.jmx.adaptor; 11 12 import org.jboss.axis.encoding.DeserializationContext; 13 import org.jboss.axis.encoding.Deserializer; 14 import org.jboss.axis.encoding.DeserializerImpl; 15 import org.jboss.axis.encoding.Target; 16 import org.jboss.axis.encoding.TypeMapping; 17 import org.jboss.axis.message.SOAPHandler; 18 import org.xml.sax.Attributes ; 19 import org.xml.sax.SAXException ; 20 21 import javax.management.Attribute ; 22 import javax.xml.namespace.QName ; 23 24 33 public class AttributeDeser extends DeserializerImpl 34 { 35 36 40 protected String attributeName; 41 protected Object attributeValue; 42 protected QName xmlType; 43 44 48 public AttributeDeser(Class javaClass, QName xmlType) 49 { 50 this.xmlType = xmlType; 51 } 52 53 54 public void onStartElement(String namespace, 55 String localName, 56 String qName, 57 Attributes attributes, 58 DeserializationContext context) 59 throws SAXException 60 { 61 attributeName = attributes.getValue("", "name"); 62 } 63 64 65 public SOAPHandler onStartChild(String namespace, 66 String localName, 67 String prefix, 68 Attributes attributes, 69 DeserializationContext context) 70 throws SAXException 71 { 72 if (localName.equals("value") && namespace.equals("")) 73 { 74 QName qn = 75 context.getTypeFromAttributes(namespace, localName, attributes); 76 Deserializer dSer = context.getDeserializerForType(qn); 78 if (dSer == null) 82 { 83 dSer = new DeserializerImpl(); 84 TypeMapping tm = context.getTypeMapping(); 86 dSer.setDefaultType(tm.getTypeQName(Object .class)); 87 dSer.registerValueTarget(new AttributeValueTarget()); 88 } 89 return (SOAPHandler)dSer; 90 } 91 else 92 { 93 return null; 94 } 95 } 96 97 101 public void onEndElement(String namespace, 102 String localName, 103 DeserializationContext context) 104 throws SAXException 105 { 106 if (isNil) 107 { 108 value = null; 109 return; 110 } 111 112 value = new Attribute (attributeName, attributeValue); 113 } 114 115 119 protected class AttributeValueTarget implements Target 120 { 121 public void set(Object value) throws SAXException 122 { 123 attributeValue = value; 124 } 125 } 126 127 } 128 | Popular Tags |