The following documentation was generated automatically by 'BshDoc' from Javadoc style comments in the BeanShell command script files. See "BshDoc" for more information.
void addClassPath( string | URL ) |
|
Thread bg( String filename ) |
|
bind ( bsh .This ths , bsh .NameSpace namespace ) |
|
void browseClass( String | Object | Class ) |
|
cat ( String filename ) |
|
void cd ( String pathname ) |
|
classBrowser ( ) |
|
clear ( ) |
|
cp ( String fromFile , String toFile ) |
|
debug ( ) |
|
void desktop() |
|
String dirname ( String pathname ) |
|
editor ( ) |
|
void error ( item ) |
|
Object eval ( String expression ) |
|
exec ( String arg ) |
|
exit ( ) |
|
This extend( This object ) |
|
Frame | JFrame | JInternalFrame frame( Component component ) |
|
String getBshPrompt ( ) |
|
Class getClass ( String name ) |
|
URL [ ] getClassPath ( ) |
|
URL getResource ( String path ) |
|
getSourceFileInfo ( ) |
|
void importCommands( resource path | package name ) |
|
void javap( String | Object | Class | ClassIdentifier ) |
|
Object load ( String filename ) |
|
makeWorkspace ( String name ) |
|
mv ( String fromFile , String toFile ) |
|
This object() |
|
File pathToFile ( String filename ) |
|
void print ( arg ) |
|
printBanner ( ) |
|
pwd ( ) |
|
void reloadClasses( [ package name ] ) |
|
boolean rm ( String pathname ) |
|
run ( String filename , Object runArgument ) |
|
void save ( Object obj , String filename ) |
|
void server ( int port ) |
|
setAccessibility ( boolean b ) |
|
void setClassPath( URL [] ) |
|
Font setFont ( Component comp , int ptsize ) |
|
void setNameCompletion ( boolean bool ) |
|
setNameSpace ( ns ) |
|
void setStrictJava ( boolean val ) |
|
show ( ) |
|
Object source ( String filename ) |
|
sourceRelative ( String file ) |
|
This super( String scopename ) |
|
void unset ( String name ) |
|
which( classIdentifier | string | class ) |
|
workspaceEditor( bsh.Interpreter parent, String name ) |
Add the specified directory or JAR file to the class path. e.g. addClassPath( "/home/pat/java/classes" ); addClassPath( "/home/pat/java/mystuff.jar" ); addClassPath( new URL("http://myserver/~pat/somebeans.jar") ); |
Source a command in its own thread in the caller's namespace This is like run() except that it runs the command in its own thread. Returns the Thread object control. |
Bind a bsh object into a particular namespace and interpreter |
Open the class browser to view the specified class. 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. Note: To browse the String class you can't supply a String. You'd have to do: browseClass( String.class ); |
cat |
Print the contents of filename, url, or stream (like Unix cat) |
Change working directory for dir(), etc. commands (like Unix cd) |
Open the class browser. |
Clear all variables, methods, and imports from this namespace. If this namespace is the root, it will be reset to the default imports. See NameSpace.clear(); |
Copy a file (like Unix cp). |
Toggle on and off debug mode. Debug output is verbose and generally useful only for developers. |
Start the BeanShell GUI desktop. |
Return directory portion of path based on the system default file separator. Note: you should probably use pathToFile() to localize the path relative to BeanShell's working directory and then file.getAbsolutePath() to get back to a system localized string. Example: to change to the directory that contains the script we're currently executing: // Change to the directory containing this script path=pathToFile( getSourceFileInfo() ).getAbsolutePath(); cd( dirname( path ) ); |
Open a GUI editor from the command line or in the GUI desktop mode. When run from the command line the editor is a simple standalone frame. When run inside the GUI desktop it is a workspace editor. See workspaceEditor() |
Print the item as an error. In the GUI console the text will show up in (something like) red, else it will be printed to standard error. |
Evaluate the string in the current interpreter (see source()). Returns the result of the evaluation or null. Evaluate a string as if it were written directly in the current scope, with side effects in the current scope. e.g.
eval() acts just like invoked text except that any exceptions generated by the code are captured in a bsh.EvalError. This includes ParseException for syntactic errors and TargetError for exceptions thrown by the evaluated code. e.g. try { eval("foo>>><>M>JK$LJLK$"); } catch ( EvalError e ) { // ParseException caught here } try { eval("(Integer)true"); // illegal cast } catch ( EvalError e ) { // TargetException caught here print( e.getTarget() ) // prints ClassCastException } If you want eval() to throw target exceptions directly, without wrapping them, you can simply redefine own eval like so: myEval( String expression ) { try { return eval( expression ); } catch ( TargetError e ) { throw e.getTarget(); } } Here is a cute example of how to use eval to implement a dynamic cast. i.e. to cast a script to an arbitrary type by name at run-time where the type is not known when you are writing the script. In this case the type is in the variable interfaceType. reference = eval( "("+interfaceType+")this" ); Returns the value of the expression. Throws bsh.EvalError on error |
Start an external application using the Java Runtime exec() method. Display any output to the standard BeanShell output using print(). |
Conditionally exit the virtual machine. Call System.exit(0) unless bsh.system.shutdownOnExit == false. |
Return a new object that is a child of the specified object. Note: this command will likely change along with a better inheritance mechanism for bsh in a future release. extend() is like the object() command, which creates a new bsh scripted object, except that the namespace of the new object is a child of the parent object. For example: foo=object(); bar=extend(foo); is equivalent to: foo() { bar() { return this; } } foo=foo(); bar=foo.bar(); and also: oo=object(); ar=object(); ar.namespace.bind( foo.namespace ); The last example above is exactly what the extend() command does. In each case the bar object inherits variables from foo in the usual way. |
Get the value to display for the bsh interactive prompt. This command checks for the variable bsh.prompt and uses it if set. else returns "bsh % " Remember that you can override bsh commands simply by defining the method in your namespace. e.g. the following method displays the current working directory in your prompt: String getBshPrompt() { return bsh.cwd + " % "; } |
Get a class through the current namespace utilizing the current imports, extended classloader, etc. This is equivalent to the standard Class.forName() method for class loading, however it takes advantage of the BeanShell class manager so that added classpath will be taken into account. You can also use Class.forName(), however if you have modified the classpath or reloaded classes from within your script the modifications will only appear if you use the getClass() command. |
Get the current classpath including all user path, extended path, and the bootstrap JAR file if possible. |
Get a resource from the BeanShell classpath. This method takes into account modification to the BeanShell class path via addClassPath() and setClassPath(); |
Return the name of the file or source from which the current interpreter is reading. Note that if you use this within a method, the result will not be the file from which the method was sourced, but will be the file that the caller of the method is reading. Methods are sourced once but can be called many times... Each time the interpreter may be associated with a different file and it is that calling interpreter that you are asking for information. Note: although it may seems like this command would always return the getSourceFileInfo.bsh file, it does not since it is being executed after sourcing by the caller's interpreter. If one wanted to know the file from which a bsh method was sourced one would have to either capture that info when the file was sourced (by saving the state of the getSourceFileInfo() in a variable outside of the method or more generally we could add the info to the BshMethod class so that bsh methods remember from what source they were created... |
Load a serialized Java object from filename. Returns the object. |
Open a new workspace (JConsole) in the GUI desktop. |
Rename a file (like Unix mv). |
Return an "empty" BeanShell object context which can be used to hold data items. e.g. myStuff = object(); myStuff.foo = 42; myStuff.bar = "blah"; |
Create a File object corresponding to the specified file path name, taking into account the bsh current working directory (bsh.cwd) |
Print the string value of the argument, which may be of any type. If beanshell is running interactively, the output will always go to the command line, otherwise it will go to System.out. Most often the printed value of an object will simply be the Java toString() of the object. However if the argument is an array the contents of the array will be (recursively) listed in a verbose way. Note that you are always free to use System.out.println() instead of print(). |
Print the BeanShell banner (version and author line) - GUI or non GUI. |
Print the BeanShell working directory. This is the cwd obeyed by all the unix-like bsh commands. |
Reload the specified class, package name, or all classes if no name is given. e.g. reloadClasses(); reloadClasses("mypackage.*"); reloadClasses(".*") // reload unpackaged classes reloadClasses("mypackage.MyClass") See "Class Path Management" |
Remove a file (like Unix rm). |
Save a serializable Java object to filename. |
Create a remote BeanShell listener service attached to the current interpreter, listening on the specified port. |
Setting accessibility on enables to private and other non-public fields and method. |
Change the classpath to the specified array of directories and/or archives. See "Class Path Management" for details. |
Change the point size of the font on the specified component, to ptsize. This is just a convenience for playing with GUI components. |
Allow users to turn off name completion. Turn name completion in the GUI console on or off. Name competion is on by default. Explicitly setting it to true however can be used to prompt bsh to read the classpath and provide immediate feedback. (Otherwise this may happen behind the scenes the first time name completion is attempted). Setting it to false will disable name completion. |
Set the namespace (context) of the current scope. The following example illustrates swapping the current namespace. fooState = object(); barState = object(); print(this.namespace); setNameSpace(fooState.namespace); print(this.namespace); a=5; setNameSpace(barState.namespace); print(this.namespace); a=6; setNameSpace(fooState.namespace); print(this.namespace); print(a); // 5 setNameSpace(barState.namespace); print(this.namespace); print(a); // 6 You could use this to creates the effect of a static namespace for a method by explicitly setting the namespace upon entry. |
Enable or disable "Strict Java Mode". When strict Java mode is enabled BeanShell will:
|
Toggle on or off displaying the results of expressions (off by default). When show mode is on bsh will print() the value returned by each expression you type on the command line. |
Source a file relative to the callering script's directory. e.g. scripts A running in dir A sources script B in dir B. Script B can use this command to load additional scripts (data, etc.) relative to its own location (dir B) without having to explicitly know its "home" directory (B). Note: this only works for files currently. |
Return a BeanShell 'this' reference to the enclosing scope (method scope) of the specified name. e.g. foo() { x=1; bar() { x=2; gee() { x=3; print( x ); // 3 print( super.x ); // 2 print( super("foo").x ); // 1 } } } This is an experimental command that is not intended to be of general use. |
"Undefine" the variable specifed by 'name' (So that it tests == void). Note: there will be a better way to do this in the future. This is currently equivalent to doing namespace.setVariable(name, null); |
Use classpath mapping to determine the source of the specified class file. (Like the Unix which command for executables). 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.: print( getResource("/com/foo/MyClass.class") ); // Same as... // System.out.println( // getClass().getResourceAsStream("/com/foo/MyClass.class" ) ); Note: This is all a lie! This command is broken and only reports the currently first occurence! To be fixed! |
workspaceEditor |
Make a new workspaceEditor in the GUI. |