The Environment provides base functions for all script interpreters. It is automatically loaded by any interpreter upon startup.
| loadModule | Load a module. Loading a module generally enhances the script environment with new functions and variables. If a module was already loaded before, it gets refreshed and moved to the top of the module stack. When a module is loaded, all its dependencies are loaded too. So loading one module might change the whole module stack. |
|---|---|
| wrap | Creates wrapper functions for a given java instance. Searches for members and methods annotated with {@link WrapToScript} and creates wrapping code in the target script language. A method named <instance>.myMethod() will be made available by calling myMethod(). |
| findModule | Resolves a loaded module and returns the Java instance. Will only query previously loaded modules. |
| eval | Execute script code. This method executes script code directly in the running interpreter. Execution is done in the same thread as the caller thread. |
| exit | Terminates script execution immediately. Code following this command will not be executed anymore. |
| include | Include and execute a script file. Quite similar to eval(Object) a source file is opened and its content is executed. Multiple sources are available: "workspace://" opens a file relative to the workspace root, "project://" opens a file relative to the current project, "file://" opens a file from the file system. All other types of URIs are supported too (like http:// ...). You may also use absolute and relative paths as defined by your local file system. |
| listModules | List all available (visible) modules. Returns a list of visible modules. Loaded modules are indicated. |
| Print to standard output. |
java.lang.Object loadModule(java.lang.String identifier)
Load a module. Loading a module generally enhances the script environment with new functions and variables. If a module was already loaded before, it gets refreshed and moved to the top of the module stack. When a module is loaded, all its dependencies are loaded too. So loading one module might change the whole module stack.
| Parameter | Type | Description |
|---|---|---|
| identifier | java.lang.String |
java.lang.Object ...
void wrap(java.lang.Object toBeWrapped)
Creates wrapper functions for a given java instance. Searches for members and methods annotated with {@link WrapToScript} and creates wrapping code in the target script language. A method named <instance>.myMethod() will be made available by calling myMethod().
| Parameter | Type | Description |
|---|---|---|
| toBeWrapped | java.lang.Object | instance to be wrapped |
java.lang.Object findModule(java.lang.String name)
Resolves a loaded module and returns the Java instance. Will only query previously loaded modules.
| Parameter | Type | Description |
|---|---|---|
| name | java.lang.String | name of the module to resolve |
java.lang.Object ...
java.lang.Object eval(java.lang.Object data)
Execute script code. This method executes script code directly in the running interpreter. Execution is done in the same thread as the caller thread.
| Parameter | Type | Description |
|---|---|---|
| data | java.lang.Object | code to be interpreted |
java.lang.Object ...
void exit(java.lang.Object value)
Terminates script execution immediately. Code following this command will not be executed anymore.
| Parameter | Type | Description |
|---|---|---|
| value | java.lang.Object | return code |
java.lang.Object include(java.lang.String filename)
Include and execute a script file. Quite similar to eval(Object) a source file is opened and its content is executed. Multiple sources are available: "workspace://" opens a file relative to the workspace root, "project://" opens a file relative to the current project, "file://" opens a file from the file system. All other types of URIs are supported too (like http:// ...). You may also use absolute and relative paths as defined by your local file system.
| Parameter | Type | Description |
|---|---|---|
| filename | java.lang.String | name of file to be included |
java.lang.Object ...
java.lang.String listModules()
List all available (visible) modules. Returns a list of visible modules. Loaded modules are indicated.
java.lang.String ...
void print(java.lang.Object text)
Print to standard output.
| Parameter | Type | Description |
|---|---|---|
| text | java.lang.Object | text to write to standard output |