public interface BSFEngine
extends java.beans.PropertyChangeListener
When a scripting engine is first fired up, the initialize() method is called right after construction.
A scripting engine must provide two access points for applications to call into them: via function calls and via expression evaluation. It must also support loading scripts.
A scripting engine is a property change listener and will be notified when any of the relevant properties of the manager change. (See BSFManager to see which of its properties are bound.)
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
apply(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object funcBody,
java.util.Vector paramNames,
java.util.Vector arguments)
This is used by an application to invoke an anonymous function.
|
java.lang.Object |
call(java.lang.Object object,
java.lang.String name,
java.lang.Object[] args)
This is used by an application to call into the scripting engine
to make a function/method call.
|
void |
compileApply(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object funcBody,
java.util.Vector paramNames,
java.util.Vector arguments,
CodeBuffer cb)
This is used by an application to compile an anonymous function.
|
void |
compileExpr(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object expr,
CodeBuffer cb)
This is used by an application to compile a value-returning expression.
|
void |
compileScript(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object script,
CodeBuffer cb)
This is used by an application to compile some script.
|
void |
declareBean(BSFDeclaredBean bean)
Declare a bean after the engine has been started.
|
java.lang.Object |
eval(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object expr)
This is used by an application to evaluate an expression.
|
void |
exec(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object script)
This is used by an application to execute some script.
|
void |
iexec(java.lang.String source,
int lineNo,
int columnNo,
java.lang.Object script)
This is used by an application to execute some script, as though
one were interacting with the language in an interactive session.
|
void |
initialize(BSFManager mgr,
java.lang.String lang,
java.util.Vector declaredBeans)
This method is used to initialize the engine right after construction.
|
void |
terminate()
Graceful termination
|
void |
undeclareBean(BSFDeclaredBean bean)
Undeclare a previously declared bean.
|
java.lang.Object apply(java.lang.String source, int lineNo, int columnNo, java.lang.Object funcBody, java.util.Vector paramNames, java.util.Vector arguments) throws BSFException
source
- (context info) the source of this expression
(e.g., filename)lineNo
- (context info) the line number in source for exprcolumnNo
- (context info) the column number in source for exprfuncBody
- the multi-line, value returning script to evaluateparamNames
- the names of the parameters above assumesarguments
- values of the above parametersBSFException
- if anything goes wrong while doin' it.java.lang.Object call(java.lang.Object object, java.lang.String name, java.lang.Object[] args) throws BSFException
object
- object on which to make the callname
- name of the method / procedure to callargs
- the arguments to be given to the procedureBSFException
- if anything goes wrong while eval'ing a
BSFException is thrown. The reason indicates the problem.void compileApply(java.lang.String source, int lineNo, int columnNo, java.lang.Object funcBody, java.util.Vector paramNames, java.util.Vector arguments, CodeBuffer cb) throws BSFException
source
- (context info) the source of this expression
(e.g., filename)lineNo
- (context info) the line number in source for exprcolumnNo
- (context info) the column number in source for exprfuncBody
- the multi-line, value returning script to evaluateparamNames
- the names of the parameters above assumesarguments
- values of the above parameterscb
- the CodeBuffer to compile intoBSFException
- if anything goes wrong while doin' it.void compileExpr(java.lang.String source, int lineNo, int columnNo, java.lang.Object expr, CodeBuffer cb) throws BSFException
source
- (context info) the source of this expression
(e.g., filename)lineNo
- (context info) the line number in source for exprcolumnNo
- (context info) the column number in source for exprexpr
- the expression to compilecb
- the CodeBuffer to compile intoBSFException
- if anything goes wrong while compiling a
BSFException is thrown. The reason indicates the problem.void compileScript(java.lang.String source, int lineNo, int columnNo, java.lang.Object script, CodeBuffer cb) throws BSFException
source
- (context info) the source of this script
(e.g., filename)lineNo
- (context info) the line number in source for scriptcolumnNo
- (context info) the column number in source for scriptscript
- the script to compilecb
- the CodeBuffer to compile intoBSFException
- if anything goes wrong while compiling a
BSFException is thrown. The reason indicates the problem.void declareBean(BSFDeclaredBean bean) throws BSFException
bean
- the bean to declareBSFException
- if the engine cannot do this operationjava.lang.Object eval(java.lang.String source, int lineNo, int columnNo, java.lang.Object expr) throws BSFException
source
- (context info) the source of this expression
(e.g., filename)lineNo
- (context info) the line number in source for exprcolumnNo
- (context info) the column number in source for exprexpr
- the expression to evaluateBSFException
- if anything goes wrong while eval'ing a
BSFException is thrown. The reason indicates the problem.void exec(java.lang.String source, int lineNo, int columnNo, java.lang.Object script) throws BSFException
source
- (context info) the source of this expression
(e.g., filename)lineNo
- (context info) the line number in source for exprcolumnNo
- (context info) the column number in source for exprscript
- the script to executeBSFException
- if anything goes wrong while exec'ing a
BSFException is thrown. The reason indicates the problem.void iexec(java.lang.String source, int lineNo, int columnNo, java.lang.Object script) throws BSFException
source
- (context info) the source of this expression
(e.g., filename)lineNo
- (context info) the line number in source for exprcolumnNo
- (context info) the column number in source for exprscript
- the script to executeBSFException
- if anything goes wrong while exec'ing a
BSFException is thrown. The reason indicates the problem.void initialize(BSFManager mgr, java.lang.String lang, java.util.Vector declaredBeans) throws BSFException
mgr
- The BSFManager that's hosting this engine.lang
- Language string which this engine is handling.declaredBeans
- Vector of BSFDeclaredObject containing beans
that should be declared into the language runtime at init
time as best as possible.BSFException
- if anything goes wrong while init'ing a
BSFException is thrown. The reason indicates the problem.void terminate()
void undeclareBean(BSFDeclaredBean bean) throws BSFException
bean
- the bean to undeclareBSFException
- if the engine cannot do this operation