KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > mmbase > bridge > remote > generator > XMLMethod


1 /*
2  
3 This software is OSI Certified Open Source Software.
4 OSI Certified is a certification mark of the Open Source Initiative.
5  
6 The license (Mozilla version 1.0) can be read at the MMBase site.
7 See http://www.MMBase.org/license
8  
9  */

10
11 package org.mmbase.bridge.remote.generator;
12 import org.w3c.dom.*;
13 import java.util.*;
14 import java.lang.reflect.*;
15
16 /**
17  * @author Kees Jongenburger <keesj@dds.nl>
18  **/

19 public class XMLMethod extends XMLClass {
20
21     public XMLMethod(Document document) {
22         super(document);
23     }
24
25     public static XMLClass fromXML(Element xml) {
26         Document doc = xml.getOwnerDocument();
27         XMLMethod method = new XMLMethod(doc);
28         method.setXML(xml);
29         return method;
30     }
31
32     public Method getJavaMethod(Class JavaDoc clazz) {
33         Method[] methods = clazz.getMethods();
34         for (int i = 0; i < methods.length; i++) {
35             if (methods[i].getName().equals(getName())) {
36                 Class JavaDoc[] params = methods[i].getParameterTypes();
37                 List list = getParameterList();
38                 boolean ok = false;
39                 if (params != null) {
40                     if (params.length == list.size()) {
41                         ok = true;
42                         for (int p = 0; p < params.length; p++) {
43                             if (!(params[p].getName().equals(((XMLClass)list.get(p)).getOriginalName()))) {
44                                 ok = false;
45                             }
46                         }
47                     }
48                 }
49                 if (ok) {
50                     return methods[i];
51                 }
52             }
53         }
54         System.err.println("Method not found");
55         return null;
56     }
57 }
58
Popular Tags