java.lang.Object
org.gjt.sp.jedit.BeanShellFacade<T>
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
- Author:
- Matthieu Casanova
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionEvaluates the specified BeanShell expression.cacheBlock
(String id, String code, boolean namespace) Caches a block of code, returning a handle that can be passed to runCachedBlock().protected static Interpreter
createInterpreter
(NameSpace nameSpace) Evaluates the specified BeanShell expression with the global namespaceEvaluates the specified BeanShell expression.void
evalSelection
(T param, TextArea textArea) Evaluates the text selected in the specified text area.protected abstract void
handleException
(T param, String path, Throwable t) protected void
init()
Initialize things.protected abstract void
resetDefaultVariables
(NameSpace namespace) 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, String name, Object object) Set a beanshell variable in the namespace without overriding itprotected static void
This extracts an exception from a 'wrapping' exception, as BeanShell sometimes throws.
-
Field Details
-
global
-
classManager
-
-
Constructor Details
-
BeanShellFacade
protected BeanShellFacade()
-
-
Method Details
-
init
protected void init()Initialize things. It is called by the constructor. You can override it to import other packages -
evalSelection
Evaluates the text selected in the specified text area.- Parameters:
param
- some sort of parametertextArea
- the textArea
-
eval
Evaluates the specified BeanShell expression with the global namespace- Parameters:
param
- The parametercommand
- The expression- Returns:
- an object
-
eval
Evaluates the specified BeanShell expression. Errors are reported in a dialog box.- Parameters:
param
- The parameternamespace
- The namespacecommand
- The expression- Returns:
- an object
-
_eval
Evaluates the specified BeanShell expression. Unlikeeval()
, this method passes any exceptions to the caller.- Parameters:
view
- The view. Within the script, references tobuffer
,textArea
andeditPane
are determined with reference to this parameter.namespace
- The namespacecommand
- The expression- Returns:
- an object
- Throws:
Exception
- instances are thrown when various BeanShell errors occur
-
cacheBlock
Caches a block of code, returning a handle that can be passed to runCachedBlock().- Parameters:
id
- An identifier.code
- The codenamespace
- If true, the namespace will be set- Returns:
- a hsh method
- Throws:
Exception
- instances are thrown when various BeanShell errors occur
-
runCachedBlock
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()param
- a parameternamespace
- The namespace to run the code in- Returns:
- an object
- Throws:
Exception
- instances are thrown when various BeanShell errors occur
-
getNameSpace
- Returns:
- the global namespace.
-
setVariable
Set a beanshell variable in the namespace without overriding it- Parameters:
nameSpace
- the namespacename
- the name of the variableobject
- the value of the variable- Throws:
UtilEvalError
- when there is an error
-
setupDefaultVariables
- Throws:
UtilEvalError
-
resetDefaultVariables
- Throws:
UtilEvalError
-
handleException
-
createInterpreter
-
unwrapException
This extracts an exception from a 'wrapping' exception, as BeanShell sometimes throws. This gives the user a more accurate error traceback- Parameters:
e
- the exception- Throws:
Exception
- on error
-