### javax.script

# Class SimpleScriptContext

- `java.lang.Object`

- `javax.script.SimpleScriptContext`

Implemented Interfaces:
  ScriptContext

Known Direct Subclasses:
  PhpScriptContext, PhpSimpleHttpScriptContext

`public class SimpleScriptContext`
`extends java.lang.Object`
`implements ScriptContext`

The GenericScriptContext is a simple implementation of ScriptContext.

Authors:
  Nandika Jayawardana <nandika@opensource.lk>
  Sanka Samaranayake <sanka@opensource.lk>

### Fields inherited from interface javax.script.ScriptContext

`ENGINE_SCOPE`, `GLOBAL_SCOPE`

## Constructor Summary

`SimpleScriptContext()`
  The basic constructor.

## 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`

`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.

### Methods inherited from class java.lang.Object

`equals`, `getClass`, `hashCode`, `notify`, `notifyAll`, `toString`, `wait`, `wait`, `wait`

## Constructor Details

### SimpleScriptContext

    public SimpleScriptContext()

> The basic constructor. Object is special, because it has no superclass, so there is no call to super().

## Method Details

### getAttribute

    public java.lang.Object getAttribute(java.lang.String name)
                throws java.lang.IllegalArgumentException

> 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)
                throws java.lang.IllegalArgumentException

> 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:
>   `name` - 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

### getWriter

    public java.io.Writer getWriter()

> 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

### removeAttribute

    public java.lang.Object removeAttribute(java.lang.String name,
                                            int scope)
                throws java.lang.IllegalArgumentException

> 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:
>   `java.lang.IllegalArgumentException` -

### setAttribute

    public void setAttribute(java.lang.String name,
                             java.lang.Object value,
                             int scope)
                throws java.lang.IllegalArgumentException

> Sets an attribute specified by the name in specified level of scope.
> Specified by:
>   setAttribute in interface ScriptContext

> Parameters:
>   `name` - the name of the attribute
>   `value` - the value of the attribute
>   `scope` - the level of the scope

### setBindings

    public void setBindings(Bindings namespace,
                            int scope)
                throws java.lang.IllegalArgumentException

> 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