/jEdit/tags/jedit-4-3-pre5/bsh/commands/which.bsh
Unknown | 44 lines | 35 code | 9 blank | 0 comment | 0 complexity | 446162a9d84edc326fc3414f6272aa38 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, Apache-2.0, LGPL-2.0, LGPL-3.0, GPL-2.0, CC-BY-SA-3.0, LGPL-2.1, GPL-3.0, MPL-2.0-no-copyleft-exception, IPL-1.0
- /**
- Use classpath mapping to determine the source of the specified class
- file. (Like the Unix which command for executables).
- <p/>
- This command maps the entire classpath and prints all of the occurrences
- of the class. If you just want to find the first occurrence in the
- classpath (the one that will be used by Java) you can also get it by
- printing the URL of the resource. e.g.:
- <p/>
- <pre>
- print( getResource("/com/foo/MyClass.class") );
- // Same as...
- // System.out.println(
- // getClass().getResourceAsStream("/com/foo/MyClass.class" ) );
- </pre>
- <p/>
- Note: This is all a lie! This command is broken and only reports the
- currently first occurence! To be fixed!
- <p/>
- @method which( classIdentifier | string | class )
- */
- bsh.help.which= "usage: which( classIdentifier | string | class )";
- import bsh.ClassIdentifier;
- which( clas )
- {
- // make the class into a name
- Class clas;
- if ( clas instanceof ClassIdentifier )
- clas = this.namespace.identifierToClass( clas );
- if ( clas instanceof Class )
- clas = clas.getName();
- String className = clas;
- cp = this.caller.namespace.getClassManager().getClassPath();
- print ( cp.getClassSource( className ) );
- }