KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > net > jmx > adaptor > MBeanAttributeInfoDeser


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 // $Id: MBeanAttributeInfoDeser.java,v 1.4.8.1 2005/03/02 14:19:54 tdiesler Exp $
9

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.DeserializerTarget;
16 import org.jboss.axis.message.SOAPHandler;
17 import org.xml.sax.Attributes JavaDoc;
18 import org.xml.sax.SAXException JavaDoc;
19
20 import javax.management.MBeanAttributeInfo JavaDoc;
21 import javax.xml.namespace.QName JavaDoc;
22
23 /**
24  * An <code>MBeanAttributeInfoDeser</code> is be used to deserialize
25  * MBeanAttributeInfo using the <code>SOAP-ENC</code>
26  * encoding style.<p>
27  *
28  * @author <a HREF="mailto:a_taherkordi@users.sourceforge.net">Alireza Taherkordi</a>
29  * @version $Revision: 1.4.8.1 $
30  */

31 public class MBeanAttributeInfoDeser extends DeserializerImpl
32 {
33
34    private String JavaDoc name;
35    private String JavaDoc type;
36    private String JavaDoc description;
37    private boolean isReadable;
38    private boolean isWritable;
39    private boolean isIs;
40
41    public void onStartElement(String JavaDoc namespace,
42                               String JavaDoc localName,
43                               String JavaDoc prefix,
44                               Attributes JavaDoc attributes,
45                               DeserializationContext context)
46            throws SAXException JavaDoc
47    {
48
49       if (context.isNil(attributes))
50       {
51          return;
52       }
53
54       //nothing to do
55

56    }
57
58    public SOAPHandler onStartChild(String JavaDoc namespace,
59                                    String JavaDoc localName,
60                                    String JavaDoc prefix,
61                                    Attributes JavaDoc attributes,
62                                    DeserializationContext context)
63            throws SAXException JavaDoc
64    {
65
66       // Get the type
67
QName JavaDoc itemType =
68               context.getTypeFromAttributes(namespace, localName, attributes);
69       // Get the deserializer
70
Deserializer dSer = null;
71       if (itemType != null)
72       {
73          dSer = context.getDeserializerForType(itemType);
74       }
75       if (dSer == null)
76       {
77          dSer = new DeserializerImpl();
78       }
79
80       // When the value is deserialized, inform us.
81
// Need to pass the localName as a hint
82
dSer.registerValueTarget(new DeserializerTarget(this, localName));
83
84       addChildDeserializer(dSer);
85
86       return (SOAPHandler)dSer;
87    }
88
89    public void setChildValue(Object JavaDoc value, Object JavaDoc hint) throws SAXException JavaDoc
90    {
91       if (hint.equals("name"))
92          name = (String JavaDoc)value;
93       else if (hint.equals("type"))
94          type = (String JavaDoc)value;
95       else if (hint.equals("description"))
96          description = (String JavaDoc)value;
97       else if (hint.equals("isReadable"))
98          isReadable = ((Boolean JavaDoc)value).booleanValue();
99       else if (hint.equals("isWritable"))
100          isWritable = ((Boolean JavaDoc)value).booleanValue();
101       else if (hint.equals("isIs"))
102          isIs = ((Boolean JavaDoc)value).booleanValue();
103
104    }
105
106    public void onEndElement(String JavaDoc s,
107                             String JavaDoc s1,
108                             DeserializationContext deserializationcontext)
109    {
110       try
111       {
112          super.value =
113                  new MBeanAttributeInfo JavaDoc(name,
114                          type,
115                          description,
116                          isReadable,
117                          isWritable,
118                          isIs);
119       }
120       catch (Exception JavaDoc exception)
121       {
122          exception.printStackTrace();
123       }
124    }
125
126 }
127
Popular Tags