## org.gjt.sp.jedit
Class BeanShellFacade<T>

    java.lang.Object
      org.gjt.sp.jedit.BeanShellFacade<T>

    public abstract class BeanShellFacade<T>

extends java.lang.Object

This class will be the interface for beanshell interaction. In jEdit it will be used with the static methods of `BeanShell`

Since:
  jEdit 4.3pre13

Field Summary
`protected BshClassManager` `classManager`
`protected NameSpace` `global`

Constructor Summary
`protected` `BeanShellFacade()`

Method Summary
`java.lang.Object` `_eval(T view, NameSpace namespace, java.lang.String command)` Evaluates the specified BeanShell expression.
`BshMethod` `cacheBlock(java.lang.String id, java.lang.String code, boolean namespace)` Caches a block of code, returning a handle that can be passed to runCachedBlock().
`protected static Interpreter` `createInterpreter(NameSpace nameSpace)`
`java.lang.Object` `eval(T param, NameSpace namespace, java.lang.String command)` Evaluates the specified BeanShell expression.
`java.lang.Object` `eval(T param, java.lang.String command)` Evaluates the specified BeanShell expression with the global namespace
`void` `evalSelection(T param, TextArea textArea)` Evaluates the text selected in the specified text area.
`NameSpace` `getNameSpace()` Returns the global namespace.
`protected abstract void` `handleException(T param, java.lang.String path, java.lang.Throwable t)`
`protected void` `init()` Initialize things.
`protected abstract void` `resetDefaultVariables(NameSpace namespace)`
`java.lang.Object` `runCachedBlock(BshMethod method, T param, NameSpace namespace)` Runs a cached block of code in the specified namespace.
`protected abstract void` `setupDefaultVariables(NameSpace namespace, T param)`
`protected void` `setVariable(NameSpace nameSpace, java.lang.String name, java.lang.Object object)` Set a beanshell variable in the namespace without overriding it
`protected static void` `unwrapException(java.lang.Exception e)` This extracts an exception from a 'wrapping' exception, as BeanShell sometimes throws.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### global

    protected NameSpace global

### classManager

    protected BshClassManager classManager

Constructor Detail

### BeanShellFacade

    protected BeanShellFacade()

Method Detail

### init

    protected void init()

  Initialize things. It is called by the constructor. You can override it to import other packages

### evalSelection

    public void evalSelection(T param,
                              TextArea textArea)

  Evaluates the text selected in the specified text area.

### eval

    public java.lang.Object eval(T param,
                                 java.lang.String command)

  Evaluates the specified BeanShell expression with the global namespace

  Parameters:
    `param` - The parameter
    `command` - The expression

### eval

    public java.lang.Object eval(T param,
                                 NameSpace namespace,
                                 java.lang.String command)

  Evaluates the specified BeanShell expression. Errors are reported in a dialog box.

  Parameters:
    `param` - The parameter
    `namespace` - The namespace
    `command` - The expression

### _eval

    public java.lang.Object _eval(T view,
                                  NameSpace namespace,
                                  java.lang.String command)
                           throws java.lang.Exception

  Evaluates the specified BeanShell expression. Unlike `eval()`, this method passes any exceptions to the caller.

  Parameters:
    `view` - The view. Within the script, references to `buffer`, `textArea` and `editPane` are determined with reference to this parameter.
    `namespace` - The namespace
    `command` - The expression
  Throws:
    `java.lang.Exception` - instances are thrown when various BeanShell errors occur

### cacheBlock

    public BshMethod cacheBlock(java.lang.String id,
                                java.lang.String code,
                                boolean namespace)
                         throws java.lang.Exception

  Caches a block of code, returning a handle that can be passed to runCachedBlock().

  Parameters:
    `id` - An identifier.
    `code` - The code
    `namespace` - If true, the namespace will be set
  Throws:
    `java.lang.Exception` - instances are thrown when various BeanShell errors occur

### runCachedBlock

    public java.lang.Object runCachedBlock(BshMethod method,
                                           T param,
                                           NameSpace namespace)
                                    throws java.lang.Exception

  Runs a cached block of code in the specified namespace. Faster than evaluating the block each time.

  Parameters:
    `method` - The method instance returned by cacheBlock()
    `namespace` - The namespace to run the code in
  Throws:
    `java.lang.Exception` - instances are thrown when various BeanShell errors occur

### getNameSpace

    public NameSpace getNameSpace()

  Returns the global namespace.

### setVariable

    protected void setVariable(NameSpace nameSpace,
                               java.lang.String name,
                               java.lang.Object object)
                        throws UtilEvalError

  Set a beanshell variable in the namespace without overriding it

  Parameters:
    `nameSpace` - the namespace
    `name` - the name of the variable
    `object` - the value of the variable
  Throws:
    `UtilEvalError`

### setupDefaultVariables

    protected abstract void setupDefaultVariables(NameSpace namespace,
                                                  T param)
                                           throws UtilEvalError

  Throws:
    `UtilEvalError`

### resetDefaultVariables

    protected abstract void resetDefaultVariables(NameSpace namespace)
                                           throws UtilEvalError

  Throws:
    `UtilEvalError`

### handleException

    protected abstract void handleException(T param,
                                            java.lang.String path,
                                            java.lang.Throwable t)

### createInterpreter

    protected static Interpreter createInterpreter(NameSpace nameSpace)

### unwrapException

    protected static void unwrapException(java.lang.Exception e)
                                   throws java.lang.Exception

  This extracts an exception from a 'wrapping' exception, as BeanShell sometimes throws. This gives the user a more accurate error traceback

  Throws:
    `java.lang.Exception`