01: package jaxx;
02:
03: import java.beans.*;
04: import java.lang.reflect.*;
05:
06: import jaxx.compiler.*;
07: import jaxx.introspection.*;
08: import jaxx.reflect.*;
09: import jaxx.reflect.MethodDescriptor;
10: import jaxx.tags.*;
11:
12: /** Generates information about a tag for use on the jaxxframework.org web site. */
13: public class PrintTagInfo {
14: /** Displays information about the class name in arg[0].
15: *
16: *@param arg command-line arguments
17: *@throws Exception if an error occurs
18: */
19: public static void main(String[] arg) throws Exception {
20: JAXXCompiler.init();
21:
22: ClassDescriptor beanClass = ClassDescriptorLoader
23: .getClassDescriptor(arg[0]);
24: DefaultObjectHandler handler = TagManager
25: .getTagHandler(beanClass);
26:
27: DefaultObjectHandler super Handler = TagManager
28: .getTagHandler(beanClass.getSuperclass());
29:
30: // dump all bean properties
31: System.out.println("Properties in " + beanClass);
32: JAXXPropertyDescriptor[] properties = handler.getJAXXBeanInfo()
33: .getJAXXPropertyDescriptors();
34: JAXXPropertyDescriptor[] super Properties = super Handler
35: .getJAXXBeanInfo().getJAXXPropertyDescriptors();
36: for (int i = 0; i < properties.length; i++) {
37: if (properties[i].getWriteMethodDescriptor() == null)
38: continue;
39:
40: boolean found = false;
41: String name = properties[i].getName();
42: for (int j = 0; j < super Properties.length; j++) {
43: if (super Properties[j].getName().equals(name)) {
44: found = true;
45: break;
46: }
47: }
48: if (!found) {
49: if (properties[i].getPropertyType() == null)
50: System.err.println(name + " has null type");
51: else {
52: System.out.println("{{EquivalentAttribute|"
53: + name
54: + "|"
55: + arg[0].replace('.', '/')
56: + "|set"
57: + JAXXCompiler.capitalize(name)
58: + "|"
59: + JAXXCompiler
60: .getCanonicalName(properties[i]
61: .getPropertyType()) + "}}");
62: System.out.println("|-");
63: }
64: }
65: }
66:
67: System.out.println();
68: System.out.println();
69:
70: // dump all bound methods
71: MethodDescriptor[] methods = beanClass.getMethodDescriptors();
72: System.out.println("Bound methods in " + beanClass);
73: for (int i = 0; i < methods.length; i++) {
74: try {
75: if (handler.isMemberBound(methods[i].getName()))
76: System.out.println("* <tt>" + methods[i].getName()
77: + "()</tt>");
78: } catch (Throwable e) {
79: }
80: }
81: }
82: }
|