org.eclipse.ease.modules

## Interface IEnvironment

All Known Implementing Classes:
  EnvironmentModule

    public interface IEnvironment

### Method Summary

All Methods Static Methods Instance Methods Abstract Methods Default Methods
`void` `addModuleCallback(IModuleCallbackProvider callbackProvider)` Register a callback provider for module functions.
`void` `addModuleListener(IModuleListener listener)`
`static IEnvironment` `getEnvironment()`
`static IEnvironment` `getEnvironment(IScriptEngine engine)`
`java.lang.Object` `getModule(java.lang.String name)`
`<T,U extends java.lang.Class<T>> T` `getModule(U clazz)`
`java.util.List<java.lang.Object>` `getModules()` Retrieve a list of loaded modules.
`IScriptEngine` `getScriptEngine()`
`java.lang.Object` `loadModule(java.lang.String moduleIdentifier, boolean useCustomNamespace)` Load a module.
`void` `print(java.lang.Object text, boolean lineFeed)` Print to standard output.
`void` `removeModuleListener(IModuleListener listener)`
`java.lang.Object` `wrap(java.lang.Object toBeWrapped, boolean useCustomNamespace)` Wrap a java instance.

### Method Detail

#### getEnvironment

    static IEnvironment getEnvironment(IScriptEngine engine)

#### getEnvironment

    static IEnvironment getEnvironment()

#### getScriptEngine

    IScriptEngine getScriptEngine()

#### getModule

    java.lang.Object getModule(java.lang.String name)

#### getModule

    <T,U extends java.lang.Class<T>> T getModule(U clazz)

#### getModules

    java.util.List<java.lang.Object> getModules()

Retrieve a list of loaded modules. The returned list is read only.

Returns:
  list of modules (might be empty)

#### print

    void print(java.lang.Object text,
               boolean lineFeed)

Print to standard output.

Parameters:
  `text` - message to write
  `lineFeed` - `true` to add a line feed after the text

#### addModuleListener

    void addModuleListener(IModuleListener listener)

#### removeModuleListener

    void removeModuleListener(IModuleListener listener)

#### loadModule

    java.lang.Object loadModule(java.lang.String moduleIdentifier,
                                @ScriptParameter(defaultValue="false")
                                boolean useCustomNamespace)

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.

When not using a custom namespace all variables and functions are loaded to the global namespace, possibly overriding existing functions. In such cases the Java module instance is returned. When useCustomNamespace is used a dynamic script object is created and returned.In such cases the global namespace is not changed. The namespace behavior is also used for loading dependencies.

Parameters:
  `moduleIdentifier` - name of module to load
  `useCustomNamespace` - set to `true` if functions and constants should not be stored to the global namespace but to a custom object
Returns:
  loaded module instance

#### wrap

    java.lang.Object wrap(java.lang.Object toBeWrapped,
                          boolean useCustomNamespace)

Wrap a java instance. Will create accessors in the target language for methods and constants defined by the java instance toBeWrapped. If the instance contains annotations of type `WrapToScript` only these will be wrapped. If no annotation can be found, all public methods/constants will be wrapped. As some target languages might not support method overloading this might result in some methods not wrapped correctly.

Parameters:
  `toBeWrapped` - instance to be wrapped
  `useCustomNamespace` - set to `true` if functions and constants should not be stored to the global namespace but to the return value only
Returns:
  wrapped object instance or java class when put to global namespace

#### addModuleCallback

    void addModuleCallback(IModuleCallbackProvider callbackProvider)

Register a callback provider for module functions.

Parameters:
  `callbackProvider` - callback provider instance