KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > test > xml > multispaced > XMBeanMetaDataProvider


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

7 package org.jboss.test.xml.multispaced;
8
9 import org.jboss.xb.binding.MarshallingContext;
10 import org.jboss.xb.binding.ObjectModelProvider;
11
12 /**
13  * @version <tt>$Revision: 1.3.2.2 $</tt>
14  * @author <a HREF="mailto:alex@jboss.org">Alexey Loubyansky</a>
15  */

16 public class XMBeanMetaDataProvider
17    implements ObjectModelProvider
18 {
19    public static final XMBeanMetaDataProvider INSTANCE = new XMBeanMetaDataProvider();
20
21    private XMBeanMetaDataProvider() {}
22
23    public Object JavaDoc getRoot(Object JavaDoc o, MarshallingContext ctx, String JavaDoc namespaceURI, String JavaDoc localName)
24    {
25       return o;
26    }
27
28    public Object JavaDoc getChildren(XMBeanMetaData xmbean, String JavaDoc namespaceUri, String JavaDoc localName)
29    {
30       Object JavaDoc children;
31       if("mbean".equals(localName))
32       {
33          children = xmbean;
34       }
35       else if("constructor".equals(localName))
36       {
37          children = xmbean.getConstructors();
38       }
39       else if("attribute".equals(localName))
40       {
41          children = xmbean.getAttributes();
42       }
43       else if("operation".equals(localName))
44       {
45          children = xmbean.getOperations();
46       }
47       else if("notification".equals(localName))
48       {
49          children = xmbean.getNotifications();
50       }
51       else if("persistence".equals(localName))
52       {
53          children = xmbean.getPersistenceManager();
54       }
55       else
56       {
57          children = null;
58       }
59       return children;
60    }
61
62    public Object JavaDoc getElementValue(XMBeanMetaData xmbean, String JavaDoc namespaceUri, String JavaDoc localName)
63    {
64       Object JavaDoc value;
65       if("description".equals(localName))
66       {
67          value = xmbean.getDescription();
68       }
69       else if("class".equals(localName))
70       {
71          value = xmbean.getMbeanClass();
72       }
73       else
74       {
75          value = null;
76       }
77       return value;
78    }
79
80    public Object JavaDoc getElementValue(XMBeanConstructorMetaData constructor, String JavaDoc namespaceUri, String JavaDoc localName)
81    {
82       Object JavaDoc value;
83       if("description".equals(localName))
84       {
85          value = constructor.getDescription();
86       }
87       else if("name".equals(localName))
88       {
89          value = constructor.getName();
90       }
91       else
92       {
93          value = null;
94       }
95       return value;
96    }
97
98    public Object JavaDoc getAttributeValue(XMBeanAttributeMetaData attribute, String JavaDoc namespaceUri, String JavaDoc localName)
99    {
100       Object JavaDoc value;
101       if("access".equals(localName))
102       {
103          value = attribute.getAccess();
104       }
105       else if("getMethod".equals(localName))
106       {
107          value = attribute.getGetMethod();
108       }
109       else if("setMethod".equals(localName))
110       {
111          value = attribute.getSetMethod();
112       }
113       else
114       {
115          value = null;
116       }
117       return value;
118    }
119
120    public Object JavaDoc getElementValue(XMBeanAttributeMetaData attribute, String JavaDoc namespaceUri, String JavaDoc localName)
121    {
122       Object JavaDoc value;
123       if("description".equals(localName))
124       {
125          value = attribute.getDescription();
126       }
127       else if("name".equals(localName))
128       {
129          value = attribute.getName();
130       }
131       else if("type".equals(localName))
132       {
133          value = attribute.getType();
134       }
135       else
136       {
137          value = null;
138       }
139       return value;
140    }
141
142    public Object JavaDoc getElementValue(XMBeanOperationMetaData operation, String JavaDoc namespaceUri, String JavaDoc localName)
143    {
144       Object JavaDoc value;
145       if("description".equals(localName))
146       {
147          value = operation.getDescription();
148       }
149       else if("name".equals(localName))
150       {
151          value = operation.getName();
152       }
153       else if("return-type".equals(localName))
154       {
155          value = operation.getReturnType();
156       }
157       else
158       {
159          value = null;
160       }
161       return value;
162    }
163
164    public Object JavaDoc getElementValue(XMBeanNotificationMetaData notification, String JavaDoc namespaceUri, String JavaDoc localName)
165    {
166       Object JavaDoc value;
167       if("description".equals(localName))
168       {
169          value = notification.getDescription();
170       }
171       else if("name".equals(localName))
172       {
173          value = notification.getName();
174       }
175       else if("notification-type".equals(localName))
176       {
177          value = notification.getNotificationType();
178       }
179       else
180       {
181          value = null;
182       }
183       return value;
184    }
185 }
186
Popular Tags