javax.script
Class SimpleScriptContext

java.lang.Object
  extended by javax.script.SimpleScriptContext
All Implemented Interfaces:
ScriptContext
Direct Known Subclasses:
GenericHttpScriptContext

public class SimpleScriptContext
extends java.lang.Object
implements ScriptContext

See Javadoc of Java Scripting API


Field Summary
protected  Bindings engineScope
          namespace of the scope of level ENGINE_SCOPE
protected  Bindings globalScope
          namespace of the scope of level GLOBAL_SCOPE
 
Fields inherited from interface javax.script.ScriptContext
ENGINE_SCOPE, GLOBAL_SCOPE
 
Constructor Summary
SimpleScriptContext()
           
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Retrieves the value for 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 associated with specified name in the specified level of scope.
 int getAttributesScope(java.lang.String name)
          Retrieves the lowest value of scopes for which the attribute is defined.
 Bindings getBindings(int scope)
          Retrieves the Namespace instance associated with the specified level of 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 specified attribute form the specified level of scope.
 void setAttribute(java.lang.String name, java.lang.Object value, int scope)
          Sets an attribute specified by the name in specified level of scope.
 void setBindings(Bindings namespace, int scope)
          Associates the specified namespace with specified level of scope.
 void setErrorWriter(java.io.Writer writer)
           
 void setReader(java.io.Reader reader)
           
 void setWriter(java.io.Writer writer)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

globalScope

protected Bindings globalScope
namespace of the scope of level GLOBAL_SCOPE


engineScope

protected Bindings engineScope
namespace of the scope of level ENGINE_SCOPE

Constructor Detail

SimpleScriptContext

public SimpleScriptContext()
Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
Retrieves the value for getAttribute(String, int) for the lowest scope in which it returns a non-null value.

Specified by:
getAttribute in interface ScriptContext
Parameters:
name - the name of the attribute
Returns:
the value of the attribute

getAttribute

public java.lang.Object getAttribute(java.lang.String name,
                                     int scope)
Retrieves the value associated with specified name in the specified level of scope. Returns null if no value is associated with specified key in specified level of scope.

Specified by:
getAttribute in interface ScriptContext
Parameters:
key - the name of the attribute
scope - the level of scope
Returns:
the value value associated with the specified name in specified level of scope

getAttributesScope

public int getAttributesScope(java.lang.String name)
Retrieves the lowest value of scopes for which the attribute is defined. If there is no associate scope with the given attribute (-1) is returned.

Specified by:
getAttributesScope in interface ScriptContext
Parameters:
name - the name of attribute
Returns:
the value of level of scope

getBindings

public Bindings getBindings(int scope)
Retrieves the Namespace instance associated with the specified level of scope.

Specified by:
getBindings in interface ScriptContext
Parameters:
scope - the level of the scope
Returns:
the namespace associated with the specified level of scope

removeAttribute

public java.lang.Object removeAttribute(java.lang.String name,
                                        int scope)
Removes the specified attribute form the specified level of scope.

Specified by:
removeAttribute in interface ScriptContext
Parameters:
name - the name of the attribute
scope - the level of scope
Returns:
value which is removed
Throws:

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value,
                         int scope)
Sets an attribute specified by the name in specified level of scope.

Specified by:
setAttribute in interface ScriptContext
Parameters:
key - the name of the attribute
value - the value of the attribute
scope - the level of the scope
Throws:
IllegalArguementException - if the name is null scope is invlaid

setBindings

public void setBindings(Bindings namespace,
                        int scope)
Associates the specified namespace with specified level of scope.

Specified by:
setBindings in interface ScriptContext
Parameters:
namespace - the namespace to be associated with specified level of scope
scope - the level of scope

getScopes

public java.util.List getScopes()
Specified by:
getScopes in interface ScriptContext

getReader

public java.io.Reader getReader()
Specified by:
getReader in interface ScriptContext

setReader

public void setReader(java.io.Reader reader)
Specified by:
setReader in interface ScriptContext

getWriter

public java.io.Writer getWriter()
Description copied from interface: ScriptContext
Retrieves an instance of java.io.Writer which can be used by scripts to display their output.

Specified by:
getWriter in interface ScriptContext
Returns:
an instance of java.io.Writer

setWriter

public void setWriter(java.io.Writer writer)
Specified by:
setWriter in interface ScriptContext

getErrorWriter

public java.io.Writer getErrorWriter()
Specified by:
getErrorWriter in interface ScriptContext

setErrorWriter

public void setErrorWriter(java.io.Writer writer)
Specified by:
setErrorWriter in interface ScriptContext


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