1 42 43 package org.jfree.xml.generator.model; 44 45 import java.beans.BeanInfo ; 46 import java.beans.IndexedPropertyDescriptor ; 47 import java.beans.IntrospectionException ; 48 import java.beans.Introspector ; 49 import java.beans.PropertyDescriptor ; 50 51 54 public class PrintBeanInfo { 55 56 private PrintBeanInfo () 57 { 58 } 59 60 65 public static void print (final Class c) { 66 try { 67 System.out.println("Class: " + c.getName()); 68 System.out.println( 69 "========================================================================" 70 ); 71 final BeanInfo bi = Introspector.getBeanInfo(c, c.getSuperclass()); 72 final PropertyDescriptor [] pd = bi.getPropertyDescriptors(); 73 for (int i = 0; i < pd.length; i++) { 74 System.out.println ("Property: " + pd[i].getDisplayName()); 75 System.out.println( 76 "---------------------------------------------------------------------" 77 ); 78 System.out.println (" ( " + pd[i].getShortDescription() + ")"); 79 if (pd[i] instanceof IndexedPropertyDescriptor ) { 80 final IndexedPropertyDescriptor id = (IndexedPropertyDescriptor ) pd[i]; 81 System.out.println (" - idx-type : " + id.getIndexedPropertyType()); 82 System.out.println (" - idx-read : " + id.getIndexedReadMethod()); 83 System.out.println (" - idx-write : " + id.getIndexedWriteMethod()); 84 } 85 else { 86 System.out.println (" - type : " + pd[i].getPropertyType()); 87 System.out.println (" - read : " + pd[i].getReadMethod()); 88 System.out.println (" - write : " + pd[i].getWriteMethod()); 89 } 90 System.out.println (" - bound : " + pd[i].isBound()); 91 System.out.println (" - constrained: " + pd[i].isConstrained()); 92 } 93 } 94 catch (IntrospectionException ie) { 95 ie.printStackTrace(); 96 } 97 } 98 99 106 public static void main(final String [] args) throws Exception { 107 for (int i = 0; i < args.length; i++) { 108 print(Class.forName(args[i])); 109 } 110 } 111 112 } 113 | Popular Tags |