org.eclipse.ease.modules

## Class AbstractEnvironment

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

All Implemented Interfaces:
  IEnvironment, IScriptModule

Direct Known Subclasses:
  EnvironmentModule, NativeEnvironment

    public abstract class AbstractEnvironment
    extends AbstractScriptModule
    implements IEnvironment

### Constructor Summary

Constructors
Constructor and Description
`AbstractEnvironment()`

### Method Summary

Methods
`void` `addModuleListener(IModuleListener listener)`
`static IEnvironment` `getEnvironment(IScriptEngine engine)`
`Object` `getModule(String name)` Resolves a loaded module and returns the Java instance.
`<T,U extends Class<T>> T` `getModule(U clazz)` Resolves a loaded module by its class.
`List<Object>` `getModules()` Retrieve a list of loaded modules.
`void` `initialize(IScriptEngine engine, IEnvironment environment)` Provides script engine and environment instances.
`String` `listModules()` List all available (visible) modules.
`Object` `loadModule(String identifier)` Load a module.
`void` `print(Object text)` Print to standard output.
`void` `removeModuleListener(IModuleListener listener)`

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

`getScriptEngine`

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

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

### Methods inherited from interface org.eclipse.ease.modules.IEnvironment

`getScriptEngine, wrap`

### Constructor Detail

#### AbstractEnvironment

    public AbstractEnvironment()

### Method Detail

#### loadModule

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

Specified by:
  `loadModule` in interface `IEnvironment`
Parameters:
  `name` - name of module to load
Returns:
  loaded module instance

#### initialize

    public void initialize(IScriptEngine engine,
                  IEnvironment environment)

Description copied from interface: `IScriptModule`
Provides script engine and environment instances.

Specified by:
  `initialize` in interface `IScriptModule`
Overrides:
  `initialize` in class `AbstractScriptModule`
Parameters:
  `engine` - script engine this module is loaded in
  `environment` - environment module that tracks this module

#### listModules

    public final String listModules()

List all available (visible) modules. Returns a list of visible modules. Loaded modules are indicated.

Returns:
  string containing module information

#### getModule

    public final Object getModule(String name)

Resolves a loaded module and returns the Java instance. Will only query previously loaded modules.

Specified by:
  `getModule` in interface `IEnvironment`
Parameters:
  `name` - name of the module to resolve
Returns:
  resolved module instance or `null`

#### getModule

    public <T,U extends Class<T>> T getModule(U clazz)

Resolves a loaded module by its class.

Specified by:
  `getModule` in interface `IEnvironment`
Parameters:
  `clazz` - module class to look resolve
Returns:
  resolved module instance or `null`

#### getModules

    public List<Object> getModules()

Description copied from interface: `IEnvironment`
Retrieve a list of loaded modules. The returned list is read only.

Specified by:
  `getModules` in interface `IEnvironment`
Returns:
  list of modules (might be empty)

#### print

    public final void print(@ScriptParameter(defaultValue="")
             Object text)

Description copied from interface: `IEnvironment`
Print to standard output.

Specified by:
  `print` in interface `IEnvironment`
Parameters:
  `text` - text to write to standard output

#### addModuleListener

    public void addModuleListener(IModuleListener listener)

Specified by:
  `addModuleListener` in interface `IEnvironment`

#### removeModuleListener

    public void removeModuleListener(IModuleListener listener)

Specified by:
  `removeModuleListener` in interface `IEnvironment`

#### getEnvironment

    public static IEnvironment getEnvironment(IScriptEngine engine)