javax.script
Interface ScriptContext

All Known Subinterfaces:
HttpScriptContext
All Known Implementing Classes:
GenericHttpScriptContext, SimpleScriptContext

public interface ScriptContext

See Javadoc of Java Scripting API


Field Summary
static int ENGINE_SCOPE
          defines an integer for the level of scope, ENGINE_SCOPE
static int GLOBAL_SCOPE
          defines an integer for the level of scope, GLOBAL_SCOPE
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Retrieves the value of the getAttribute(String, int) for the lowest scope in which it returns a non-null value.
 java.lang.Object getAttribute(java.lang.String name, int scope)
          Retrieves the value of an attribute in the specified scope.
 int getAttributesScope(java.lang.String name)
          Retrieves the lowest value of the scope for which the attribute is defined.
 Bindings getBindings(int scope)
          Retrieves the Namespace instance associated with the gieve scope.
 java.io.Writer getErrorWriter()
           
 java.io.Reader getReader()
           
 java.util.List getScopes()
           
 java.io.Writer getWriter()
          Retrieves an instance of java.io.Writer which can be used by scripts to display their output.
 java.lang.Object removeAttribute(java.lang.String name, int scope)
          Removes the given attribute form the specified scope.
 void setAttribute(java.lang.String key, java.lang.Object value, int scope)
          Associates a specified value with the specifed name in the specified scope.
 void setBindings(Bindings bindings, int scope)
          Associates the specified namespace with the specified scope.
 void setErrorWriter(java.io.Writer writer)
           
 void setReader(java.io.Reader reader)
           
 void setWriter(java.io.Writer writer)
           
 

Field Detail

ENGINE_SCOPE

static final int ENGINE_SCOPE
defines an integer for the level of scope, ENGINE_SCOPE

See Also:
Constant Field Values

GLOBAL_SCOPE

static final int GLOBAL_SCOPE
defines an integer for the level of scope, GLOBAL_SCOPE

See Also:
Constant Field Values
Method Detail

getAttribute

java.lang.Object getAttribute(java.lang.String name)
Retrieves the value of the getAttribute(String, int) for the lowest scope in which it returns a non-null value. Returns null if there is no such value exists in any scope.

Parameters:
name - the name of the attribute
Returns:
the associated value with the specified name
Throws:
java.lang.IllegalArgumentException - if the name is null

getAttribute

java.lang.Object getAttribute(java.lang.String name,
                              int scope)
Retrieves the value of an attribute in the specified scope. Returns null if the no such value exists in the specified scope.

Parameters:
name - the name of the attribute
scope - the value of the scope
Returns:
the associated value for the specified name
Throws:
java.lang.IllegalArgumentException - if the name is null or the scope is invalid

getAttributesScope

int getAttributesScope(java.lang.String name)
Retrieves the lowest value of the scope for which the attribute is defined.

Parameters:
name - the name of attribute
Returns:
the value corresponding to lowest value of the scope or -1 if no associated value exist in any scope

getBindings

Bindings getBindings(int scope)
Retrieves the Namespace instance associated with the gieve scope. Returns null if no namespace is assoicited with specified level of scope.

Parameters:
scope - the level of the scope
Returns:
the Namespace associated with the specified levle of scope

getWriter

java.io.Writer getWriter()
Retrieves an instance of java.io.Writer which can be used by scripts to display their output.

Returns:
an instance of java.io.Writer

getErrorWriter

java.io.Writer getErrorWriter()

setWriter

void setWriter(java.io.Writer writer)

setErrorWriter

void setErrorWriter(java.io.Writer writer)

getReader

java.io.Reader getReader()

setReader

void setReader(java.io.Reader reader)

removeAttribute

java.lang.Object removeAttribute(java.lang.String name,
                                 int scope)
Removes the given attribute form the specified scope. Returns the removed object or null if no value is associated with the specified key in specified level of scope.

Parameters:
name - the name of the attribute
scope - the level of scope which inherit the attribute
Returns:
previous value associated with specified name
Throws:
java.lang.IllegalArgumentException - if the name is null or if the scope is invalid

setAttribute

void setAttribute(java.lang.String key,
                  java.lang.Object value,
                  int scope)
Associates a specified value with the specifed name in the specified scope.

Parameters:
key - the name of the attribute
value - the value of the attribute
scope - the level of the scope
Throws:
java.lang.IllegalArgumentException - if the name is null or the scope is invalid

setBindings

void setBindings(Bindings bindings,
                 int scope)
Associates the specified namespace with the specified scope.

Parameters:
bindings - the namespace to be associated with the specified level of scope
scope - the specified level of scope
Throws:
java.lang.IllegalArgumentException - if the scope is invalid
java.lang.NullPointerException - if the bindings is null and the scope is ScriptEngine.ENGINE_SCOPE

getScopes

java.util.List getScopes()


Copyright © 1999-2008 Apache Software Foundation. All Rights Reserved.