public abstract class AbstractScriptEngine extends Job implements IScriptEngine
Constructor and Description |
---|
AbstractScriptEngine(String name)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
addExecutionListener(IExecutionListener listener) |
ScriptResult |
executeAsync(Object content)
Execute script code asynchronously.
|
ScriptResult |
executeSync(Object content)
Execute script code synchronously.
|
static String[] |
extractArguments(String arguments) |
EngineDescription |
getDescription()
Get engine description for current engine.
|
PrintStream |
getErrorStream() |
Object |
getExecutedFile()
Get the currently executed file instance.
|
InputStream |
getInputStream() |
PrintStream |
getOutputStream() |
List<IScriptDebugFrame> |
getStackTrace() |
boolean |
getTerminateOnIdle()
Get termination condition when engine is idle.
|
Object |
getVariable(String name)
Get a script variable.
|
Map<String,Object> |
getVariables()
Get all variables from the scope.
|
boolean |
hasVariable(String name)
Check if a variable exists within the scope of the engine.
|
Object |
inject(Object content)
Inject script code and execute synchronously.
|
Object |
injectUI(Object content)
Inject script code and execute synchronously within the UI thread.
|
boolean |
isIdle()
Get idle status of the interpreter.
|
void |
removeExecutionListener(IExecutionListener listener) |
Object |
removeVariable(String name)
Remove a variable from the scope.
|
void |
reset()
Resets the script engine to a fresh state (removes all variables and code history).
|
void |
setCloseStreamsOnTerminate(boolean closeStreams)
Set marker to automatically close I/O streams when engine is terminated.
|
void |
setEngineDescription(EngineDescription description) |
void |
setErrorStream(OutputStream errorStream)
Set the default error stream for the interpreter.
|
void |
setInputStream(InputStream inputStream)
Set the default input stream for the interpreter.
|
void |
setOutputStream(OutputStream outputStream)
Set the default output stream for the interpreter.
|
void |
setTerminateOnIdle(boolean terminate)
Set a marker that the interpreter should terminate instead entering IDLE mode.
|
void |
setVariable(String name,
Object content)
Set a variable in the script engine.
|
void |
terminate()
Terminate this interpreter.
|
addJobChangeListener, belongsTo, cancel, create, done, getJobManager, getName, getPriority, getProperty, getResult, getRule, getState, getThread, isBlocking, isSystem, isUser, join, removeJobChangeListener, schedule, schedule, setName, setPriority, setProgressGroup, setProperty, setRule, setSystem, setThread, setUser, shouldRun, shouldSchedule, sleep, toString, wakeUp, wakeUp, yieldRule
getAdapter
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
getName, getSaveVariableName, registerJar, schedule, terminateCurrent
getAdapter
public AbstractScriptEngine(String name)
name
- name of script engine jobpublic EngineDescription getDescription()
IScriptEngine
getDescription
in interface IScriptEngine
public final ScriptResult executeAsync(Object content)
IScriptEngine
Reader
object, or a File
special treatment is done, otherwise the toString() method is used to extract script code.executeAsync
in interface IScriptEngine
content
- content to be executed.public final ScriptResult executeSync(Object content) throws InterruptedException
IScriptEngine
Reader
object, or a File
special treatment is done, otherwise the toString() method is used to extract script code.
The calling thread is stalled until the script code is processed.executeSync
in interface IScriptEngine
content
- content to be executed.InterruptedException
- when execution is interruptedpublic final Object inject(Object content)
IScriptEngine
inject
in interface IScriptEngine
content
- content to be executed.public final Object injectUI(Object content)
IScriptEngine
injectUI
in interface IScriptEngine
content
- content to be executed.public void setCloseStreamsOnTerminate(boolean closeStreams)
IScriptEngine
setCloseStreamsOnTerminate
in interface IScriptEngine
closeStreams
- true
to close streamspublic PrintStream getOutputStream()
getOutputStream
in interface IScriptEngine
public void setOutputStream(OutputStream outputStream)
IScriptEngine
setOutputStream
in interface IScriptEngine
outputStream
- default output streampublic InputStream getInputStream()
getInputStream
in interface IScriptEngine
public void setInputStream(InputStream inputStream)
IScriptEngine
setInputStream
in interface IScriptEngine
inputStream
- default input streampublic PrintStream getErrorStream()
getErrorStream
in interface IScriptEngine
public void setErrorStream(OutputStream errorStream)
IScriptEngine
setErrorStream
in interface IScriptEngine
errorStream
- default error streampublic final void setTerminateOnIdle(boolean terminate)
IScriptEngine
setTerminateOnIdle
in interface IScriptEngine
terminate
- true
to request terminationpublic boolean getTerminateOnIdle()
IScriptEngine
getTerminateOnIdle
in interface IScriptEngine
true
when engine is terminated when idlepublic boolean isIdle()
isIdle
in interface IScriptEngine
public void addExecutionListener(IExecutionListener listener)
addExecutionListener
in interface IScriptEngine
public void removeExecutionListener(IExecutionListener listener)
removeExecutionListener
in interface IScriptEngine
public void terminate()
IScriptEngine
terminate
in interface IScriptEngine
public void reset()
IScriptEngine
reset
in interface IScriptEngine
public List<IScriptDebugFrame> getStackTrace()
public Object getExecutedFile()
IScriptEngine
getExecutedFile
in interface IScriptEngine
public void setEngineDescription(EngineDescription description)
public void setVariable(String name, Object content)
IScriptEngine
setVariable
in interface IScriptEngine
name
- variable namecontent
- variable contentpublic Object getVariable(String name)
IScriptEngine
getVariable
in interface IScriptEngine
name
- variable namenull
public boolean hasVariable(String name)
IScriptEngine
null
, IScriptEngine.getVariable(String)
might not be
sufficient to query.hasVariable
in interface IScriptEngine
name
- variable nametrue
when variable existspublic Object removeVariable(String name)
IScriptEngine
removeVariable
in interface IScriptEngine
name
- variable to be removed.public Map<String,Object> getVariables()
IScriptEngine
getVariables
in interface IScriptEngine