package org.jboss.net.jmx.adaptor;
import org.jboss.axis.encoding.DeserializationContext;
import org.jboss.axis.encoding.Deserializer;
import org.jboss.axis.encoding.DeserializerImpl;
import org.jboss.axis.encoding.Target;
import org.jboss.axis.encoding.TypeMapping;
import org.jboss.axis.message.SOAPHandler;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import javax.management.Attribute;
import javax.xml.namespace.QName;
public class AttributeDeser extends DeserializerImpl
{
protected String attributeName;
protected Object attributeValue;
protected QName xmlType;
public AttributeDeser(Class javaClass, QName xmlType)
{
this.xmlType = xmlType;
}
public void onStartElement(String namespace,
String localName,
String qName,
Attributes attributes,
DeserializationContext context)
throws SAXException
{
attributeName = attributes.getValue("", "name");
}
public SOAPHandler onStartChild(String namespace,
String localName,
String prefix,
Attributes attributes,
DeserializationContext context)
throws SAXException
{
if (localName.equals("value") && namespace.equals(""))
{
QName qn =
context.getTypeFromAttributes(namespace, localName, attributes);
Deserializer dSer = context.getDeserializerForType(qn);
if (dSer == null)
{
dSer = new DeserializerImpl();
TypeMapping tm = context.getTypeMapping();
dSer.setDefaultType(tm.getTypeQName(Object.class));
dSer.registerValueTarget(new AttributeValueTarget());
}
return (SOAPHandler)dSer;
}
else
{
return null;
}
}
public void onEndElement(String namespace,
String localName,
DeserializationContext context)
throws SAXException
{
if (isNil)
{
value = null;
return;
}
value = new Attribute(attributeName, attributeValue);
}
protected class AttributeValueTarget implements Target
{
public void set(Object value) throws SAXException
{
attributeValue = value;
}
}
}