public static void usage ( PrintStream errStream , Object target ) { Class < ? > clazz ; if ( target instanceof Class ) { clazz = ( Class ) target ; } else { clazz = target . getClass ( ) ; } errStream . println ( "Usage: " + clazz . getName ( ) ) ; for ( Class < ? > currentClazz = clazz ; currentClazz != null ; currentClazz = currentClazz . getSuperclass ( ) ) { for ( Field field : currentClazz . getDeclaredFields ( ) ) { fieldUsage ( errStream , target , field ) ; } } try { BeanInfo info = Introspector . getBeanInfo ( clazz ) ; for ( PropertyDescriptor pd : info . getPropertyDescriptors ( ) ) { propertyUsage ( errStream , target , pd ) ; } } catch ( IntrospectionException e ) { // If its not a JavaBean we ignore it } }
Generate usage information based on the target annotations .