This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.


javax.script
class AbstractScriptEngine

java.lang.Object extended by javax.script.AbstractScriptEngine
All Implemented Interfaces:
ScriptEngine

public abstract class AbstractScriptEngine
extends Object
implements ScriptEngine

Provides a standard implementation for several of the variants of the eval method.

eval(Reader)

eval(String)

eval(String, Bindings)

eval(Reader, Bindings)

are implemented using the abstract methods

eval(Reader,ScriptContext) or eval(String, ScriptContext)

with a SimpleScriptContext.

A SimpleScriptContext is used as the default ScriptContext of the AbstractScriptEngine..


Field Summary
protected ScriptContext context
          The default ScriptContext of this AbstractScriptEngine.
 
Constructor Summary

          Creates a new instance of AbstractScriptEngine using a SimpleScriptContext as its default ScriptContext.

          Creates a new instance using the specified Bindings as the ENGINE_SCOPE Bindings in the protected context field.
 
Method Summary
 Object
eval(Reader reader)

          eval(Reader) calls the abstract eval(Reader, ScriptContext) passing the value of the context field.
 Object
eval(Reader reader, Bindings bindings)

          eval(Reader, Bindings) calls the abstract eval(Reader, ScriptContext) method, passing it a ScriptContext whose Reader, Writers and Bindings for scopes other that ENGINE_SCOPE are identical to those members of the protected context field.
 Object
eval(String script)

          Same as eval(Reader) except that the abstract eval(String, ScriptContext) is used.
 Object
eval(String script, Bindings bindings)

          Same as eval(Reader, Bindings) except that the abstract eval(String, ScriptContext) is used.
 Object
get(String key)

          Gets the value for the specified key in the ENGINE_SCOPE of the protected context field.
 Bindings
getBindings(int scope)

          Returns the Bindings with the specified scope value in the protected context field.
 ScriptContext

          Returns the value of the protected context field.
protected ScriptContext

          Returns a SimpleScriptContext.
 void
put(String key, Object value)

          Sets the specified value with the specified key in the ENGINE_SCOPE Bindings of the protected context field.
 void
setBindings(Bindings bindings, int scope)

          Sets the Bindings with the corresponding scope value in the context field.
 void

          Sets the value of the protected context field to the specified ScriptContext.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

context

protected ScriptContext context
The default ScriptContext of this AbstractScriptEngine.
Constructor Detail

AbstractScriptEngine

public AbstractScriptEngine()
Creates a new instance of AbstractScriptEngine using a SimpleScriptContext as its default ScriptContext.


AbstractScriptEngine

public AbstractScriptEngine(Bindings n)
Creates a new instance using the specified Bindings as the ENGINE_SCOPE Bindings in the protected context field.

Parameters:
n - The specified Bindings.
Method Detail

eval

public Object eval(Reader reader)
            throws ScriptException
eval(Reader) calls the abstract eval(Reader, ScriptContext) passing the value of the context field.

Parameters:
reader - A Reader containing the source of the script.
Returns:
The return value from eval(Reader, ScriptContext)
Throws:
ScriptException - if an error occurs in script.

eval

public Object eval(Reader reader,
                   Bindings bindings)
            throws ScriptException
eval(Reader, Bindings) calls the abstract eval(Reader, ScriptContext) method, passing it a ScriptContext whose Reader, Writers and Bindings for scopes other that ENGINE_SCOPE are identical to those members of the protected context field. The specified Bindings is used instead of the ENGINE_SCOPE Bindings of the context field.

Parameters:
reader - A Reader containing the source of the script.
bindings - A Bindings to use for the ENGINE_SCOPE while the script executes.
Returns:
The return value from eval(Reader, ScriptContext)
Throws:
ScriptException - if an error occurs in script.

eval

public Object eval(String script)
            throws ScriptException
Same as eval(Reader) except that the abstract eval(String, ScriptContext) is used.

Parameters:
script - A String containing the source of the script.
Returns:
The return value from eval(String, ScriptContext)
Throws:
ScriptException - if an error occurrs in script.

eval

public Object eval(String script,
                   Bindings bindings)
            throws ScriptException
Same as eval(Reader, Bindings) except that the abstract eval(String, ScriptContext) is used.

Parameters:
script - A String containing the source of the script.
bindings - A Bindings to use as the ENGINE_SCOPE while the script executes.
Returns:
The return value from eval(String, ScriptContext)
Throws:
ScriptException - if an error occurs in script.

get

public Object get(String key)
Gets the value for the specified key in the ENGINE_SCOPE of the protected context field.

Parameters:
key
Returns:
The value for the specified key.

getBindings

public Bindings getBindings(int scope)
Returns the Bindings with the specified scope value in the protected context field.

Parameters:
scope - The specified scope
Returns:
The corresponding Bindings.

getContext

public ScriptContext getContext()
Returns the value of the protected context field.

Returns:
The value of the protected context field.

getScriptContext

protected ScriptContext getScriptContext(Bindings nn)
Returns a SimpleScriptContext. The SimpleScriptContext:



A SimpleScriptContext returned by this method is used to implement eval methods using the abstract eval(Reader,Bindings) and eval(String,Bindings) versions.

Parameters:
nn - Bindings to use for the ENGINE_SCOPE
Returns:
The SimpleScriptContext

put

public void put(String key,
                Object value)
Sets the specified value with the specified key in the ENGINE_SCOPE Bindings of the protected context field.

Parameters:
key - The specified key.
value - The specified value.

setBindings

public void setBindings(Bindings bindings,
                        int scope)
Sets the Bindings with the corresponding scope value in the context field.

Parameters:
bindings - The specified Bindings.
scope - The specified scope.

setContext

public void setContext(ScriptContext ctxt)
Sets the value of the protected context field to the specified ScriptContext.

Parameters:
ctxt - The specified ScriptContext.


This documentation differs from the official API. Jadeite adds extra features to the API including: variable font sizes, constructions examples, placeholders for classes and methods, and auto-generated “See Also” links. Additionally it is missing some items found in standard Javadoc documentation, including: generics type information, “Deprecated” tags and comments, “See Also” links, along with other minor differences. Please send any questions or feedback to bam@cs.cmu.edu.
This page displays the Jadeite version of the documention, which is derived from the offical documentation that contains this copyright notice:
Copyright 2008 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms. Also see the documentation redistribution policy.
The official Sun™ documentation can be found here at http://java.sun.com/javase/6/docs/api/.