KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > javax > management > compliance > signature > support > ObjectClass


1 /*
2  * Copyright (C) The MX4J Contributors.
3  * All rights reserved.
4  *
5  * This software is distributed under the terms of the MX4J License version 1.0.
6  * See the terms of the MX4J License in the documentation provided with this software.
7  */

8
9 package test.javax.management.compliance.signature.support;
10
11 /**
12  * @version $Revision: 1.3 $
13  */

14 public interface ObjectClass
15 {
16    public String JavaDoc getName();
17
18    public ObjectMethod[] getDeclaredMethods();
19
20    public ObjectMethod[] getMethods();
21
22    public ObjectClass getSuperclass();
23
24    public static class Constructor implements ObjectClass
25    {
26       private java.lang.Class JavaDoc cls;
27
28       public Constructor(Class JavaDoc cls)
29       {
30          this.cls = cls;
31       }
32
33       public String JavaDoc getName()
34       {
35          return cls.getName();
36       }
37
38       public ObjectMethod[] getDeclaredMethods()
39       {
40          java.lang.reflect.Constructor JavaDoc[] constructors = cls.getDeclaredConstructors();
41          ObjectMethod[] ctors = new ObjectMethod[constructors.length];
42          for (int i = 0; i < ctors.length; ++i) ctors[i] = new ObjectMethod.Constructor(constructors[i]);
43          return ctors;
44       }
45
46       public ObjectMethod[] getMethods()
47       {
48          java.lang.reflect.Constructor JavaDoc[] constructors = cls.getConstructors();
49          ObjectMethod[] ctors = new ObjectMethod[constructors.length];
50          for (int i = 0; i < ctors.length; ++i) ctors[i] = new ObjectMethod.Constructor(constructors[i]);
51          return ctors;
52       }
53
54       public ObjectClass getSuperclass()
55       {
56          Class JavaDoc superCls = cls.getSuperclass();
57          return superCls == null ? null : new Constructor(superCls);
58       }
59    }
60
61    public static class Method implements ObjectClass
62    {
63       private java.lang.Class JavaDoc cls;
64
65       public Method(Class JavaDoc cls)
66       {
67          this.cls = cls;
68       }
69
70       public String JavaDoc getName()
71       {
72          return cls.getName();
73       }
74
75       public ObjectMethod[] getDeclaredMethods()
76       {
77          java.lang.reflect.Method JavaDoc[] methods = cls.getDeclaredMethods();
78          ObjectMethod[] mthds = new ObjectMethod[methods.length];
79          for (int i = 0; i < mthds.length; ++i) mthds[i] = new ObjectMethod.Method(methods[i]);
80          return mthds;
81       }
82
83       public ObjectMethod[] getMethods()
84       {
85          java.lang.reflect.Method JavaDoc[] methods = cls.getMethods();
86          ObjectMethod[] mthds = new ObjectMethod[methods.length];
87          for (int i = 0; i < mthds.length; ++i) mthds[i] = new ObjectMethod.Method(methods[i]);
88          return mthds;
89       }
90
91       public ObjectClass getSuperclass()
92       {
93          Class JavaDoc superCls = cls.getSuperclass();
94          return superCls == null ? null : new Method(superCls);
95       }
96    }
97 }
98
Popular Tags