PageRenderTime 16ms CodeModel.GetById 12ms app.highlight 1ms RepoModel.GetById 1ms app.codeStats 0ms

/jEdit/tags/jedit-4-1-pre5/bsh/commands/javap.bsh

#
Unknown | 46 lines | 38 code | 8 blank | 0 comment | 0 complexity | 6542814922bf8fb006237ebb6ed4869d MD5 | raw file
 1/**
 2	Print the public fields and methods of the specified class (output similar 
 3	to the JDK javap command).
 4	<p>
 5	If the argument is a
 6	string it is considered to be a class name.  If the argument is an object,
 7	the class of the object is used.  If the arg is a class, the class is used.
 8
 9	@method void javap( String | Object | Class )
10*/
11
12bsh.help.javap= "usage: javap( value )";
13
14import bsh.Name;
15javap( Object o ) 
16{
17	import java.lang.reflect.Modifier;
18
19	if ( o instanceof Name.ClassIdentifier )
20		clas = this.namespace.identifierToClass(o);
21	if ( o instanceof String)
22		clas = this.namespace.getClass((String)o);
23	else if ( o instanceof Class )
24		clas = o;
25	else 
26		clas = o.getClass();
27	
28	print( "Class "+clas+" extends " +clas.getSuperclass() );
29
30	methods=clas.getDeclaredMethods();
31	//print("------------- Methods ----------------");
32	for(int i=0; i<methods.length; i++) {
33		m = methods[i];
34		if ( Modifier.isPublic( m.getModifiers() ) )
35			print( m );
36	}
37
38	//print("------------- Fields ----------------");
39	fields=clas.getDeclaredFields();
40	for(int i=0; i<fields.length; i++) {
41		f = fields[i];
42		if ( Modifier.isPublic( f.getModifiers() ) )
43			print( f );
44	}
45}
46