javax.script
Class CompiledScript

java.lang.Object
  extended by javax.script.CompiledScript

public abstract class CompiledScript
extends Object

Base for classes that store the results of compilations. This class is immutable. See Javadoc of Java Scripting API


Constructor Summary
CompiledScript()
           
 
Method Summary
 Object eval()
          Executes the program stored in the CompiledScript object.
 Object eval(Bindings 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.
abstract  Object eval(ScriptContext context)
          Evaluates the compiled script using the specified ScriptContext.
abstract  ScriptEngine getEngine()
          Retrieves a reference to the ScriptEngine whose methods created this CompiledScript object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CompiledScript

public CompiledScript()
Method Detail

eval

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:
the resultant object after the evaluation of the script (may be null)
Throws:
ScriptException - if evaluation fails for any reason

eval

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 - the bindings to be used as the ENGINE_SCOPE
Returns:
resultant object after the re-evaluation (may be null)
Throws:
ScriptException - if the evaluation fails for any reason

eval

public abstract Object eval(ScriptContext context)
                     throws ScriptException
Evaluates the compiled script using the specified ScriptContext.

Parameters:
context - A ScriptContext to be used in the evalution of the script
Returns:
resultant object after the evaluation (may be null)
Throws:
ScriptException - if the evaluation fails for any reason
NullPointerException - if context is null

getEngine

public abstract ScriptEngine getEngine()
Retrieves a reference to the ScriptEngine whose methods created this CompiledScript object.

Returns:
the ScriptEngine which created this CompiledScript object


Copyright © 1999-2012 The Apache Software Foundation. All Rights Reserved.