APIdia Launch Partner
Top Description Constructors Methods
javax.script

public abstract Class CompiledScript

extends Object
Class Inheritance
Imports
java.util.Map

Extended by classes that store results of compilations. State might be stored in the form of Java classes, Java class files or scripting language opcodes. The script may be executed repeatedly without reparsing.

Each CompiledScript is associated with a ScriptEngine -- A call to an eval method of the CompiledScript causes the execution of the script by the ScriptEngine. Changes in the state of the ScriptEngine caused by execution of the CompiledScript may visible during subsequent executions of scripts by the engine.
Author
Mike Grogan
Since
1.6

Constructor Summary

AccessConstructor and Description
public
CompiledScript()

Constructor for subclasses to call.

Method Summary

Modifier and TypeMethod and Description
public abstract Object

Returns:

The value returned by the script execution, if any. Should return null if no value is returned by the script execution.
eval
(ScriptContext
A ScriptContext that is used in the same way as the ScriptContext passed to the eval methods of ScriptEngine.
context
)

Executes the program stored in this CompiledScript object.

public Object

Returns:

The return value from the script execution
eval
(Bindings
The bindings of attributes used for the ENGINE_SCOPE.
bindings
)

Executes the program stored in the CompiledScript object using the supplied Bindings of attributes as the ENGINE_SCOPE of the associated ScriptEngine during script execution.

public Object

Returns:

The return value from the script execution
eval
()

Executes the program stored in the CompiledScript object.

public abstract ScriptEngine

Returns:

The ScriptEngine that created this CompiledScript
getEngine
()

Returns the ScriptEngine whose compile method created this CompiledScript.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

CompiledScriptback to summary
public CompiledScript()

Constructor for subclasses to call.

Method Detail

evalback to summary
public abstract Object eval(ScriptContext context) throws ScriptException

Executes the program stored in this CompiledScript object.

Parameters
context:ScriptContext

A ScriptContext that is used in the same way as the ScriptContext passed to the eval methods of ScriptEngine.

Returns:Object

The value returned by the script execution, if any. Should return null if no value is returned by the script execution.

Exceptions
ScriptException:
if an error occurs.
NullPointerException:
if context is null.
evalback to summary
public Object eval(Bindings bindings) throws ScriptException

Executes the program stored in the CompiledScript object using the supplied Bindings of attributes as the ENGINE_SCOPE of the associated ScriptEngine during script execution. If bindings is null, then the effect of calling this method is same as that of eval(getEngine().getContext()).

. The GLOBAL_SCOPE Bindings, Reader and Writer associated with the default ScriptContext of the associated ScriptEngine are used.

Parameters
bindings:Bindings

The bindings of attributes used for the ENGINE_SCOPE.

Returns:Object

The return value from the script execution

Exceptions
ScriptException:
if an error occurs.
evalback to summary
public Object eval() throws ScriptException

Executes the program stored in the CompiledScript object. The default ScriptContext of the associated ScriptEngine is used. The effect of calling this method is same as that of eval(getEngine().getContext()).

Returns:Object

The return value from the script execution

Exceptions
ScriptException:
if an error occurs.
getEngineback to summary
public abstract ScriptEngine getEngine()

Returns the ScriptEngine whose compile method created this CompiledScript. The CompiledScript will execute in this engine.

Returns:ScriptEngine

The ScriptEngine that created this CompiledScript