home *** CD-ROM | disk | FTP | other *** search
- /**
- Print the public fields and methods of the specified class (output similar
- to the JDK javap command).
- <p>
- If the argument is a
- string it is considered to be a class name. If the argument is an object,
- the class of the object is used. If the arg is a class, the class is used.
-
- @method void javap( String | Object | Class )
- */
-
- bsh.help.javap= "usage: javap( value )";
-
- import bsh.Name;
- javap( Object o )
- {
- import java.lang.reflect.Modifier;
-
- if ( o instanceof Name.ClassIdentifier )
- clas = this.namespace.identifierToClass(o);
- if ( o instanceof String)
- clas = this.namespace.getClass((String)o);
- else if ( o instanceof Class )
- clas = o;
- else
- clas = o.getClass();
-
- print( "Class "+clas+" extends " +clas.getSuperclass() );
-
- methods=clas.getDeclaredMethods();
- //print("------------- Methods ----------------");
- for(int i=0; i<methods.length; i++) {
- m = methods[i];
- if ( Modifier.isPublic( m.getModifiers() ) )
- print( m );
- }
-
- //print("------------- Fields ----------------");
- fields=clas.getDeclaredFields();
- for(int i=0; i<fields.length; i++) {
- f = fields[i];
- if ( Modifier.isPublic( f.getModifiers() ) )
- print( f );
- }
- }
-
-