org.eclipse.ease.modules

## Class EnvironmentModule

- java.lang.Object
- - org.eclipse.ease.modules.AbstractScriptModule
  - - org.eclipse.ease.modules.AbstractEnvironment
    - - org.eclipse.ease.modules.EnvironmentModule

All Implemented Interfaces:
  IEnvironment, IScriptModule

    public class EnvironmentModule
    extends AbstractEnvironment

The Environment provides base functions for all script interpreters. It is automatically loaded by any interpreter upon startup.

### Field Summary

Fields
`static String` `MODULE_NAME`
`static String` `MODULE_PREFIX`

### Constructor Summary

Constructors
Constructor and Description
`EnvironmentModule()`

### Method Summary

Methods
`Object` `execute(Object data)` Execute script code.
`void` `exit(Object value)` Terminates script execution immediately.
`IScriptEngine` `getScriptEngine()` Get the current script engine instance.
`void` `help(String topic)` Open help page on addressed topic.
`Object` `include(String filename)` Include and execute a script file.
`void` `loadJar(Object location)` Add a jar file to the classpath.
`void` `wrap(Object toBeWrapped)` Creates wrapper functions for a given java instance.

### Methods inherited from class org.eclipse.ease.modules.AbstractEnvironment

`addModuleListener, getEnvironment, getModule, getModule, getModules, initialize, listModules, loadModule, print, removeModuleListener`

### Methods inherited from class java.lang.Object

`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Field Detail

#### MODULE_NAME

    public static final String MODULE_NAME

See Also:
  Constant Field Values

#### MODULE_PREFIX

    public static final String MODULE_PREFIX

See Also:
  Constant Field Values

### Constructor Detail

#### EnvironmentModule

    public EnvironmentModule()

### Method Detail

#### wrap

    public void wrap(Object toBeWrapped)

Creates wrapper functions for a given java instance. Searches for members and methods annotated with `WrapToScript` and creates wrapping code in the target script language. A method named <instance>.myMethod() will be made available by calling myMethod().

Parameters:
  `toBeWrapped` - instance to be wrapped

#### execute

    public final Object execute(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.

Parameters:
  `data` - code to be interpreted
Returns:
  result of code execution

#### exit

    public final void exit(@ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null")
            Object value)

Terminates script execution immediately. Code following this command will not be executed anymore.

Parameters:
  `value` - return code

#### include

    public final Object include(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.

Parameters:
  `filename` - name of file to be included
Returns:
  result of include operation
Throws:
  `Throwable`

#### getScriptEngine

    public IScriptEngine getScriptEngine()

Get the current script engine instance.

Specified by:
  `getScriptEngine` in interface `IEnvironment`
Overrides:
  `getScriptEngine` in class `AbstractScriptModule`
Returns:
  `IScriptEngine` instance

#### loadJar

    public void loadJar(Object location)
                 throws MalformedURLException

Add a jar file to the classpath. Contents of the jar can be accessed right after loading. location can be an URI, a path, a File or an IFile instance.

Parameters:
  `location` - URI, Path, File or IFile
Throws:
  `MalformedURLException` - invalid URL detected

#### help

    public void help(@ScriptParameter(defaultValue="org.eclipse.ease.modules.ScriptParameter.null")
            String topic)

Open help page on addressed topic. If the given topic matches a method or field from a loaded module, the definition will be opened. If the topic is unknown, a search in the whole eclipse help will be launched.

Parameters:
  `topic` - help topic to open (typically a function name)