Package org.gjt.sp.jedit
Class BeanShellFacade<T>
- java.lang.Object
-
- org.gjt.sp.jedit.BeanShellFacade<T>
-
public abstract class BeanShellFacade<T> extends java.lang.ObjectThis class will be the interface for beanshell interaction. In jEdit it will be used with the static methods ofBeanShell- Since:
- jEdit 4.3pre13
-
-
Field Summary
Fields Modifier and Type Field Description protected BshClassManagerclassManagerprotected NameSpaceglobal
-
Constructor Summary
Constructors Modifier Constructor Description protectedBeanShellFacade()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description java.lang.Object_eval(T view, NameSpace namespace, java.lang.String command)Evaluates the specified BeanShell expression.BshMethodcacheBlock(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 InterpretercreateInterpreter(NameSpace nameSpace)java.lang.Objecteval(T param, java.lang.String command)Evaluates the specified BeanShell expression with the global namespacejava.lang.Objecteval(T param, NameSpace namespace, java.lang.String command)Evaluates the specified BeanShell expression.voidevalSelection(T param, TextArea textArea)Evaluates the text selected in the specified text area.NameSpacegetNameSpace()protected abstract voidhandleException(T param, java.lang.String path, java.lang.Throwable t)protected voidinit()Initialize things.protected abstract voidresetDefaultVariables(NameSpace namespace)java.lang.ObjectrunCachedBlock(BshMethod method, T param, NameSpace namespace)Runs a cached block of code in the specified namespace.protected abstract voidsetupDefaultVariables(NameSpace namespace, T param)protected voidsetVariable(NameSpace nameSpace, java.lang.String name, java.lang.Object object)Set a beanshell variable in the namespace without overriding itprotected static voidunwrapException(java.lang.Exception e)This extracts an exception from a 'wrapping' exception, as BeanShell sometimes throws.
-
-
-
Field Detail
-
global
protected NameSpace global
-
classManager
protected BshClassManager classManager
-
-
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.- Parameters:
param- some sort of parametertextArea- the textArea
-
eval
public java.lang.Object eval(T param, java.lang.String command)
Evaluates the specified BeanShell expression with the global namespace- Parameters:
param- The parametercommand- The expression- Returns:
- an object
-
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 parameternamespace- The namespacecommand- The expression- Returns:
- an object
-
_eval
public java.lang.Object _eval(T view, NameSpace namespace, java.lang.String command) throws java.lang.Exception
Evaluates the specified BeanShell expression. Unlikeeval(), this method passes any exceptions to the caller.- Parameters:
view- The view. Within the script, references tobuffer,textAreaandeditPaneare determined with reference to this parameter.namespace- The namespacecommand- The expression- Returns:
- an object
- 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 codenamespace- If true, the namespace will be set- Returns:
- a hsh method
- 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()param- a parameternamespace- The namespace to run the code in- Returns:
- an object
- 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 namespacename- the name of the variableobject- the value of the variable- Throws:
UtilEvalError- when there is an error
-
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.ExceptionThis 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:
java.lang.Exception- on error
-
-