Class CompiledScript
java.lang.Object
javax.script.CompiledScript
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
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.- Since:
- 1.6
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptioneval()
Executes the program stored in theCompiledScript
object.Executes the program stored in theCompiledScript
object using the suppliedBindings
of attributes as theENGINE_SCOPE
of the associatedScriptEngine
during script execution.abstract Object
eval
(ScriptContext context) Executes the program stored in thisCompiledScript
object.abstract ScriptEngine
Returns theScriptEngine
whosecompile
method created thisCompiledScript
.Methods declared in class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Modifier and TypeMethodDescriptionprotected Object
clone()
Creates and returns a copy of this object.boolean
Indicates whether some other object is "equal to" this one.protected void
finalize()
Deprecated, for removal: This API element is subject to removal in a future version.Finalization is deprecated and subject to removal in a future release.final Class
<?> getClass()
Returns the runtime class of thisObject
.int
hashCode()
Returns a hash code value for this object.final void
notify()
Wakes up a single thread that is waiting on this object's monitor.final void
Wakes up all threads that are waiting on this object's monitor.toString()
Returns a string representation of the object.final void
wait()
Causes the current thread to wait until it is awakened, typically by being notified or interrupted.final void
wait
(long timeoutMillis) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.final void
wait
(long timeoutMillis, int nanos) Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
-
Constructor Details
-
CompiledScript
public CompiledScript()Constructor for subclasses to call.
-
-
Method Details
-
eval
Executes the program stored in thisCompiledScript
object.- Parameters:
context
- AScriptContext
that is used in the same way as theScriptContext
passed to theeval
methods ofScriptEngine
.- Returns:
- The value returned by the script execution, if any. Should return
null
if no value is returned by the script execution. - Throws:
ScriptException
- if an error occurs.NullPointerException
- if context is null.
-
eval
Executes the program stored in theCompiledScript
object using the suppliedBindings
of attributes as theENGINE_SCOPE
of the associatedScriptEngine
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
andWriter
associated with the defaultScriptContext
of the associatedScriptEngine
are used.- Parameters:
bindings
- The bindings of attributes used for theENGINE_SCOPE
.- Returns:
- The return value from the script execution
- Throws:
ScriptException
- if an error occurs.
-
eval
Executes the program stored in theCompiledScript
object. The defaultScriptContext
of the associatedScriptEngine
is used. The effect of calling this method is same as that of eval(getEngine().getContext()).- Returns:
- The return value from the script execution
- Throws:
ScriptException
- if an error occurs.
-
getEngine
Returns theScriptEngine
whosecompile
method created thisCompiledScript
. TheCompiledScript
will execute in this engine.- Returns:
- The
ScriptEngine
that created thisCompiledScript
-