01: /*
02: * Copyright (C) The MX4J Contributors.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the MX4J License version 1.0.
06: * See the terms of the MX4J License in the documentation provided with this software.
07: */
08:
09: package test.javax.management.compliance.signature.support;
10:
11: /**
12: * @version $Revision: 1.3 $
13: */
14: public interface ObjectClass {
15: public String getName();
16:
17: public ObjectMethod[] getDeclaredMethods();
18:
19: public ObjectMethod[] getMethods();
20:
21: public ObjectClass getSuperclass();
22:
23: public static class Constructor implements ObjectClass {
24: private java.lang.Class cls;
25:
26: public Constructor(Class cls) {
27: this .cls = cls;
28: }
29:
30: public String getName() {
31: return cls.getName();
32: }
33:
34: public ObjectMethod[] getDeclaredMethods() {
35: java.lang.reflect.Constructor[] constructors = cls
36: .getDeclaredConstructors();
37: ObjectMethod[] ctors = new ObjectMethod[constructors.length];
38: for (int i = 0; i < ctors.length; ++i)
39: ctors[i] = new ObjectMethod.Constructor(constructors[i]);
40: return ctors;
41: }
42:
43: public ObjectMethod[] getMethods() {
44: java.lang.reflect.Constructor[] constructors = cls
45: .getConstructors();
46: ObjectMethod[] ctors = new ObjectMethod[constructors.length];
47: for (int i = 0; i < ctors.length; ++i)
48: ctors[i] = new ObjectMethod.Constructor(constructors[i]);
49: return ctors;
50: }
51:
52: public ObjectClass getSuperclass() {
53: Class super Cls = cls.getSuperclass();
54: return super Cls == null ? null : new Constructor(super Cls);
55: }
56: }
57:
58: public static class Method implements ObjectClass {
59: private java.lang.Class cls;
60:
61: public Method(Class cls) {
62: this .cls = cls;
63: }
64:
65: public String getName() {
66: return cls.getName();
67: }
68:
69: public ObjectMethod[] getDeclaredMethods() {
70: java.lang.reflect.Method[] methods = cls
71: .getDeclaredMethods();
72: ObjectMethod[] mthds = new ObjectMethod[methods.length];
73: for (int i = 0; i < mthds.length; ++i)
74: mthds[i] = new ObjectMethod.Method(methods[i]);
75: return mthds;
76: }
77:
78: public ObjectMethod[] getMethods() {
79: java.lang.reflect.Method[] methods = cls.getMethods();
80: ObjectMethod[] mthds = new ObjectMethod[methods.length];
81: for (int i = 0; i < mthds.length; ++i)
82: mthds[i] = new ObjectMethod.Method(methods[i]);
83: return mthds;
84: }
85:
86: public ObjectClass getSuperclass() {
87: Class super Cls = cls.getSuperclass();
88: return super Cls == null ? null : new Method(superCls);
89: }
90: }
91: }
|