PageRenderTime 49ms CodeModel.GetById 46ms app.highlight 1ms RepoModel.GetById 0ms app.codeStats 1ms

/jEdit/tags/jedit-4-2-pre14/bsh/commands/which.bsh

#
Unknown | 44 lines | 35 code | 9 blank | 0 comment | 0 complexity | 446162a9d84edc326fc3414f6272aa38 MD5 | raw file
 1/**
 2	Use classpath mapping to determine the source of the specified class
 3	file.  (Like the Unix which command for executables).
 4	<p/>
 5
 6    This command maps the entire classpath and prints all of the occurrences
 7    of the class.  If you just want to find the first occurrence in the
 8    classpath (the one that will be used by Java) you can also get it by
 9    printing the URL of the resource. e.g.:
10	<p/>
11
12    <pre>
13        print( getResource("/com/foo/MyClass.class") );
14		// Same as...
15        // System.out.println(
16        //    getClass().getResourceAsStream("/com/foo/MyClass.class" ) );
17    </pre>
18	<p/>
19
20	Note: This is all a lie! This command is broken and only reports the
21	currently first occurence! To be fixed!
22	<p/>
23
24	@method which( classIdentifier | string | class )
25*/
26
27bsh.help.which= "usage: which( classIdentifier | string | class )";
28
29import bsh.ClassIdentifier;
30
31which( clas ) 
32{
33	// make the class into a name
34	Class clas;
35	if ( clas instanceof ClassIdentifier )
36		clas = this.namespace.identifierToClass( clas );
37	if ( clas instanceof Class )
38		clas = clas.getName();
39	String className = clas;
40
41	cp = this.caller.namespace.getClassManager().getClassPath();
42	print ( cp.getClassSource( className ) );
43}
44