KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ist > coach > coachEmfClientComponents > InvokeSetData


1 package ist.coach.coachEmfClientComponents;
2
3 public class InvokeSetData {
4
5     public java.lang.reflect.Method JavaDoc methodName;
6     public Object JavaDoc[] methodArguments;
7     public Class JavaDoc[] methodArgumentTypes;
8     public Class JavaDoc objectClass;
9
10     public InvokeSetData(Class JavaDoc objectClass,
11                         java.lang.reflect.Method JavaDoc methodName,
12                         Object JavaDoc[] methodArguments,
13                         Class JavaDoc[] methodArgumentTypes) {
14
15         this.objectClass = objectClass;
16         this.methodName = methodName;
17         this.methodArguments = methodArguments;
18         this.methodArgumentTypes = methodArgumentTypes;
19     }
20
21     public InvokeSetData(String JavaDoc object_Class,
22                         String JavaDoc method_Name,
23                         Object JavaDoc[] method_Arguments) {
24
25         try {
26
27             objectClass = Class.forName(object_Class);
28
29             methodArgumentTypes = new Class JavaDoc[method_Arguments.length];
30             methodArguments = method_Arguments;
31
32             for(int i = 0; i < methodArgumentTypes.length; i++) {
33
34                 //System.err.println("1) methodArgument = " +
35
// method_Arguments[i].getClass().getName());
36
if (method_Arguments[i] instanceof Integer JavaDoc) {
37                   methodArgumentTypes[i] = Integer.TYPE;
38                   //method_ArgumentsTypes[i] = int.class;
39
System.err.println("HELLO1!");
40               }
41               else
42                   methodArgumentTypes[i] = //Class.forName(method_ArgumentTypes[i]);
43
method_Arguments[i].getClass();
44
45                 //System.err.println("2) methodArgument = " +
46
// methodArgumentTypes[i].getName());
47
}
48
49             methodName = objectClass.getMethod(method_Name, methodArgumentTypes);
50
51         }
52         catch(java.lang.IllegalArgumentException JavaDoc e1) {
53             System.err.println("InvokeSetData> IllegalArgumentException ");
54         }
55         //catch(java.lang.IllegalAccessException e2) {
56
// System.err.println("InvokeSetData> IllegalAccessException ");
57
//}
58
catch(java.lang.ClassNotFoundException JavaDoc e3) {
59             System.err.println("InvokeSetData> ClassNotFoundException " +
60                 e3.getMessage());
61         }
62         catch(java.lang.NoSuchMethodException JavaDoc e4) {
63             System.err.println("InvokeSetData> NoSuchMethodException " +
64                 e4.getMessage());
65             e4.printStackTrace();
66         }
67         //catch(java.lang.reflect.InvocationTargetException e5) {
68
// System.err.println("InvokeSetData> InvocationTargetException");
69
//}
70

71     }
72
73 }
74
Popular Tags