BeanShell Object Management Commands
Prev | Chapter 16. BeanShell Commands | Next

## BeanShell Object Management Commands

- `bind(`bsh.This ths, bsh.Namespace namespace`)`;

  Binds the scripted object `ths` to `namespace`.

- `void clear(``void)`;

  Clear all variables, methods, and imports from this namespace. If this namespace is the root, it will be reset to the default imports.

- `bsh.This extend(`bsh.This object`)`;

  Creates a new BeanShell `This` scripted object that is a child of the parameter `object`.

- `void importObject(`Object object`)`;

  Import an object into this namespace. This is somewhat similar to Java 1.5 static class imports, except you can import the methods and fields of a Java object instance into a BeanShell namespace, for example:

      Map map = new HashMap();
          importObject( map );
          put("foo", "bar");
          print( get("foo") ); // "bar"

- `bsh.This object(``void)`;

  Creates a new BeanShell `This` scripted object which can hold data members. You can use this to create an object for storing miscellaneous crufties, like so:

      crufties = object();
      crufties.foo = "hello world";
      crufties.counter = 5;
      ...

- `setNameSpace(`bsh.Namespace namespace`)`;

  Set the namespace of the current scope to `namespace`.

- `bsh.This super(`String scopename`)`;

  Returns a reference to the BeanShell `This` object representing the enclosing method scope specified by `scopename`. This method work similar to the `super` keyword but can refer to enclosing scope at higher levels in a hierarchy of scopes.

- `void unset(`String name`)`;

  Removes the variable named by `name` from the current interpreter namespace. This has the effect of “undefining” the variable.

Prev | Up | Next
Script Execution Commands | Home | Other Commands