php.java.script
Class ScriptContextDecorator

java.lang.Object
  extended by php.java.script.ScriptContextDecorator
All Implemented Interfaces:
ScriptContext
Direct Known Subclasses:
AbstractPhpScriptContext

public abstract class ScriptContextDecorator
extends java.lang.Object
implements ScriptContext

Abstract class for ScriptContexts. The abstract class itself provides default methods that pass all requests to the contained ScriptContext. Subclasses of ScriptContextDecorator should override some of these methods and may also provide additional methods and fields.

Author:
jostb

Field Summary
 
Fields inherited from interface javax.script.ScriptContext
ENGINE_SCOPE, GLOBAL_SCOPE
 
Constructor Summary
ScriptContextDecorator(ScriptContext ctx)
           
 
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()
          Returns the Writer used to display error output.
 java.io.Reader getReader()
          Returns a Reader to be used by the script to read input.
 java.util.List getScopes()
          Returns immutable List of all the valid values for scope in the ScriptContext.
 java.io.Writer getWriter()
          Returns the Writer for scripts to use when displaying 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 namespace, int scope)
          Associates the specified namespace with the specified scope.
 void setErrorWriter(java.io.Writer writer)
          Sets the Writer used to display error output.
 void setReader(java.io.Reader reader)
          Sets the Reader for scripts to read input .
 void setWriter(java.io.Writer writer)
          Sets the Writer for scripts to use when displaying output.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ScriptContextDecorator

public ScriptContextDecorator(ScriptContext ctx)
Method Detail

getAttribute

public java.lang.Object getAttribute(java.lang.String name)
                              throws java.lang.IllegalArgumentException
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.

Specified by:
getAttribute in interface ScriptContext
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

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

Specified by:
getAttribute in interface ScriptContext
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

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

Specified by:
getAttributesScope in interface ScriptContext
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

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

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

getErrorWriter

public java.io.Writer getErrorWriter()
Returns the Writer used to display error output.

Specified by:
getErrorWriter in interface ScriptContext
Returns:
The Writer

getReader

public java.io.Reader getReader()
Returns a Reader to be used by the script to read input.

Specified by:
getReader in interface ScriptContext
Returns:
The Reader.

getScopes

public java.util.List getScopes()
Returns immutable List of all the valid values for scope in the ScriptContext.

Specified by:
getScopes in interface ScriptContext
Returns:
list of scope values

getWriter

public java.io.Writer getWriter()
Returns the Writer for scripts to use when displaying output.

Specified by:
getWriter in interface ScriptContext
Returns:
The Writer.

removeAttribute

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

Specified by:
removeAttribute in interface ScriptContext
Parameters:
name - the name of the attribute
scope - the level of scope which inherit the attribute
Returns:
previous value associated with specified name

setAttribute

public void setAttribute(java.lang.String key,
                         java.lang.Object value,
                         int scope)
                  throws java.lang.IllegalArgumentException
Associates a specified value with the specifed name in the specified 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:
java.lang.IllegalArgumentException - if the name is null or the scope is invalid

setBindings

public void setBindings(Bindings namespace,
                        int scope)
                 throws java.lang.IllegalArgumentException
Associates the specified namespace with the specified scope.

Specified by:
setBindings in interface ScriptContext
Parameters:
namespace - 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

setErrorWriter

public void setErrorWriter(java.io.Writer writer)
Sets the Writer used to display error output.

Specified by:
setErrorWriter in interface ScriptContext
Parameters:
writer - The Writer.

setReader

public void setReader(java.io.Reader reader)
Sets the Reader for scripts to read input .

Specified by:
setReader in interface ScriptContext
Parameters:
reader - The new Reader.

setWriter

public void setWriter(java.io.Writer writer)
Sets the Writer for scripts to use when displaying output.

Specified by:
setWriter in interface ScriptContext
Parameters:
writer - The new Writer.