You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bsf-dev@jakarta.apache.org by se...@apache.org on 2009/03/25 01:21:53 UTC
svn commit: r758099 -
/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/
Author: sebb
Date: Wed Mar 25 00:21:52 2009
New Revision: 758099
URL: http://svn.apache.org/viewvc?rev=758099&view=rev
Log:
Detab
Modified:
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/AbstractScriptEngine.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Bindings.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Compilable.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/CompiledScript.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Invocable.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptContext.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngine.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineFactory.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptException.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleBindings.java
jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleScriptContext.java
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/AbstractScriptEngine.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/AbstractScriptEngine.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/AbstractScriptEngine.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/AbstractScriptEngine.java Wed Mar 25 00:21:52 2009
@@ -24,7 +24,7 @@
* See Javadoc of <a href="http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html">Java Scripting API</a>
*/
public abstract class AbstractScriptEngine implements ScriptEngine {
-
+
protected ScriptContext context;
/**
@@ -33,48 +33,48 @@
*/
public AbstractScriptEngine() {
this.context = new SimpleScriptContext();
- }
-
+ }
+
/**
* Constructs a ScriptEngine using the specified Bindings as its
* ENGINE_SCOPE.
*
* @param bindings the Bindings to be used as the ENGINE_SCOPE
*/
- public AbstractScriptEngine(Bindings bindings){
+ public AbstractScriptEngine(Bindings bindings){
this();
if (bindings == null) {
- throw new NullPointerException("bindings is null");
+ throw new NullPointerException("bindings is null");
}
context.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
- }
-
+ }
+
/** {@inheritDoc} */
public Object eval(Reader reader) throws ScriptException{
return eval(reader, context);
}
-
+
/** {@inheritDoc} */
public Object eval(Reader reader, Bindings bindings)
throws ScriptException{
return eval(reader,getScriptContext(bindings));
}
-
+
/** {@inheritDoc} */
public Object eval(String script) throws ScriptException{
return eval(script, context);
}
-
+
/** {@inheritDoc} */
public Object eval(String script, Bindings bindings) throws ScriptException{
return eval(script,getScriptContext(bindings));
}
-
+
/** {@inheritDoc} */
- public Object get(String key) {
- return getBindings(ScriptContext.ENGINE_SCOPE).get(key);
- }
-
+ public Object get(String key) {
+ return getBindings(ScriptContext.ENGINE_SCOPE).get(key);
+ }
+
/** {@inheritDoc} */
public Bindings getBindings(int scope) {
if (scope == ScriptContext.GLOBAL_SCOPE || scope == ScriptContext.ENGINE_SCOPE) {
@@ -83,8 +83,8 @@
throw new IllegalArgumentException("invalid scope");
}
}
-
-
+
+
/**
* Retrieves an instance of ScriptContext with namespaces
* associated with all the level of scopes and the specified
@@ -97,39 +97,39 @@
* @throws NullPointerException if bindings is null
*/
protected ScriptContext getScriptContext(Bindings bindings){
- if (bindings == null) {
- throw new NullPointerException("ENGINE_SCOPE bindings cannot be null");
- }
-
+ if (bindings == null) {
+ throw new NullPointerException("ENGINE_SCOPE bindings cannot be null");
+ }
+
ScriptContext scriptContext = new SimpleScriptContext();
scriptContext.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
scriptContext.setBindings(this.getBindings(ScriptContext.GLOBAL_SCOPE), ScriptContext.GLOBAL_SCOPE);
-
+
scriptContext.setReader(this.context.getReader());
scriptContext.setWriter(this.context.getWriter());
scriptContext.setErrorWriter(this.context.getErrorWriter());
-
+
return scriptContext;
}
/** {@inheritDoc} */
- public void put(String key, Object value) {
-
- if (key == null) {
+ public void put(String key, Object value) {
+
+ if (key == null) {
throw new NullPointerException("name is null");
}
-
+
if (key.length() == 0) {
throw new IllegalArgumentException("name is empty");
}
-
- getBindings(ScriptContext.ENGINE_SCOPE).put(key,value);
- }
+
+ getBindings(ScriptContext.ENGINE_SCOPE).put(key,value);
+ }
/** {@inheritDoc} */
- public void setBindings(Bindings bindings, int scope) {
-
+ public void setBindings(Bindings bindings, int scope) {
+
if (scope == ScriptContext.GLOBAL_SCOPE || scope == ScriptContext.ENGINE_SCOPE) {
context.setBindings(bindings, scope);
} else {
@@ -145,7 +145,7 @@
/** {@inheritDoc} */
public void setContext(ScriptContext context) {
if (context == null) {
- throw new NullPointerException("context is null");
+ throw new NullPointerException("context is null");
}
this.context = context;
}
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Bindings.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Bindings.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Bindings.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Bindings.java Wed Mar 25 00:21:52 2009
@@ -25,20 +25,20 @@
*/
public interface Bindings extends Map{
- /**
+ /**
* Associates the specified value with the specified key in a
* java.util.Map. If the map previously contained a mapping for
* this key, the old value is replaced.
*
- * @param key the String value which uniquely identifies the
+ * @param key the String value which uniquely identifies the
* object
- * @param value the object to be stored.
- *
+ * @param value the object to be stored.
+ *
* @throws NullPointerException if key is null
- * @throws ClassCastException if the key is not a String
- * @throws IllegalArgumentException if the key is an empty string
+ * @throws ClassCastException if the key is not a String
+ * @throws IllegalArgumentException if the key is an empty string
*/
- public Object put(Object key,Object value);
+ public Object put(Object key,Object value);
/**
* Copies all of the mappings from the specified map to this map.
@@ -66,7 +66,7 @@
* @throws IllegalArgumentException if key is empty String
*/
public boolean containsKey(Object key);
-
+
/**
* Returns the value to which this map maps the specified key.
* Returns null if the map contains no mapping for this key.
@@ -84,7 +84,7 @@
* @throws IllegalArgumentException if key is empty String
*/
public Object get(Object key);
-
+
/**
* Removes the mapping for this key from this map if it is
* present (optional operation).
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Compilable.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Compilable.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Compilable.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Compilable.java Wed Mar 25 00:21:52 2009
@@ -38,7 +38,7 @@
* @throws NullPointerException if script is null
*/
public CompiledScript compile(String script) throws ScriptException;
-
+
/**
* Retruns a CompileScript implementation for the script
* obtained using java.io.Reader as the script source.
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/CompiledScript.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/CompiledScript.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/CompiledScript.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/CompiledScript.java Wed Mar 25 00:21:52 2009
@@ -21,10 +21,10 @@
* See Javadoc of <a href="http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html">Java Scripting API</a>
*/
public abstract class CompiledScript {
-
+
public CompiledScript(){
}
-
+
/**
* Re-evaluates the pre-compiled script stored using the
* ENGINE_SCOPE and the GLOBAL_SCOPE of the associated
@@ -38,7 +38,7 @@
public Object eval() throws ScriptException {
return eval(getEngine().getContext());
}
-
+
/**
* Re-evaluates the pre-compiled script using the specified
* namespace as the SCRIPT_SCOPE and using ENGINE_SCOPE,
@@ -50,21 +50,21 @@
* reason
*/
public Object eval(Bindings bindings) throws ScriptException{
- ScriptContext context;
- if (bindings == null) {
- context = getEngine().getContext();
- } else {
+ ScriptContext context;
+ if (bindings == null) {
+ context = getEngine().getContext();
+ } else {
context = new SimpleScriptContext();
context.setBindings(bindings, ScriptContext.ENGINE_SCOPE);
- ScriptContext oldContext = getEngine().getContext();
+ ScriptContext oldContext = getEngine().getContext();
context.setBindings(oldContext.getBindings(ScriptContext.GLOBAL_SCOPE), ScriptContext.GLOBAL_SCOPE);
context.setReader(oldContext.getReader());
context.setWriter(oldContext.getWriter());
context.setErrorWriter(oldContext.getErrorWriter());
- }
- return eval(context);
+ }
+ return eval(context);
}
-
+
/**
* Re-evaluates the recompiled script using the specified
* ScriptContext.
@@ -77,7 +77,7 @@
* @throws NullPointerException if context is null
*/
public abstract Object eval(ScriptContext context) throws ScriptException;
-
+
/**
* Retrieves a reference to the ScriptEngine whose methods
* created this CompiledScript object.
@@ -86,5 +86,5 @@
* object
*/
public abstract ScriptEngine getEngine();
-
+
}
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Invocable.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Invocable.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Invocable.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/Invocable.java Wed Mar 25 00:21:52 2009
@@ -23,43 +23,43 @@
* See Javadoc of <a href="http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html">Java Scripting API</a>
*/
public interface Invocable {
-
- /**
+
+ /**
* Invokes a scripting procedure with the given name using the
* array of objects as its arguments set.
*
- * @param name name of the scripting procedure
- * @param args arguments set for the scripting procedure
- * @return resultant object after the execution of the procedure
+ * @param name name of the scripting procedure
+ * @param args arguments set for the scripting procedure
+ * @return resultant object after the execution of the procedure
* @throws ScriptException if the invocation of the scripting procedure
* fails
* @throws NoSuchMethodException if method with given name or matching
* argument types cannot be found
* @throws NullPointerException - if the method name is null.
- */
+ */
public Object invokeFunction(String name, Object[] args)
throws ScriptException, NoSuchMethodException;
-
+
/**
* Invokes a procedure on an object which already defined in the
* script using the array of objects as its arguments set.
*
- * @param thiz object on which the procedure is called
+ * @param thiz object on which the procedure is called
* @param name name of the procedure to be invoked
- * @param args arguments set for the procedure
- * @return resultant object after the execution of the
+ * @param args arguments set for the procedure
+ * @return resultant object after the execution of the
* procedure
- * @throws ScriptException if the invocation of the procedure
+ * @throws ScriptException if the invocation of the procedure
* fails
* @throws NoSuchMethodException if a method with given name or matching
* argument types cannot be found
* @throws NullPointerException - if the method name is null.
* @throws IllegalArgumentException - if the specified thiz
* is null or the specified Object is does not represent a scripting object.
- */
- public Object invokeMethod(Object thiz, String name, Object[] args) throws
+ */
+ public Object invokeMethod(Object thiz, String name, Object[] args) throws
ScriptException, NoSuchMethodException;
-
+
/**
* Retrieves an instance of java class whose methods are
* impleemented using procedures in script which are in the
@@ -72,18 +72,18 @@
* @throws IllegalArgumentException
* if the specified Class object is null or is not an interface
*/
- public Object getInterface(Class clasz);
+ public Object getInterface(Class clasz);
- /**
- *
- * @param thiz The scripting object whose member functions are used to implement the methods of the interface.
- * @param clasz The Class object of the interface to return.
- * @return An instance of requested interface.
- * Will be null if the requested interface is unavailable,
- * i.e. if compiled methods in the ScriptEngine cannot be found matching the ones in the requested interface.
- * @throws IllegalArgumentException
- * if the specified Class object is null or is not an interface,
- * or if the specified Object is null or does not represent a scripting object.
- */
- public Object getInterface(Object thiz, Class clasz);
+ /**
+ *
+ * @param thiz The scripting object whose member functions are used to implement the methods of the interface.
+ * @param clasz The Class object of the interface to return.
+ * @return An instance of requested interface.
+ * Will be null if the requested interface is unavailable,
+ * i.e. if compiled methods in the ScriptEngine cannot be found matching the ones in the requested interface.
+ * @throws IllegalArgumentException
+ * if the specified Class object is null or is not an interface,
+ * or if the specified Object is null or does not represent a scripting object.
+ */
+ public Object getInterface(Object thiz, Class clasz);
}
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptContext.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptContext.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptContext.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptContext.java Wed Mar 25 00:21:52 2009
@@ -27,13 +27,13 @@
* See Javadoc of <a href="http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html">Java Scripting API</a>
*/
public interface ScriptContext {
-
- /** defines an integer for the level of scope, ENGINE_SCOPE */
- public static final int ENGINE_SCOPE = 100;
-
- /** defines an integer for the level of scope, GLOBAL_SCOPE */
- public static final int GLOBAL_SCOPE = 200;
-
+
+ /** defines an integer for the level of scope, ENGINE_SCOPE */
+ public static final int ENGINE_SCOPE = 100;
+
+ /** defines an integer for the level of scope, GLOBAL_SCOPE */
+ public static final int GLOBAL_SCOPE = 200;
+
/**
* Retrieves the value of the getAttribute(String, int) for the
* lowest scope in which it returns a non-null value. Returns
@@ -46,7 +46,7 @@
* @throws NullPointerException if the name is null
*/
public Object getAttribute(String name);
-
+
/**
* Retrieves the value of an attribute in the specified scope.
* Returns null if the no such value exists in the specified
@@ -60,7 +60,7 @@
* @throws NullPointerException if the name is null
*/
public Object getAttribute(String name, int scope);
-
+
/**
* Retrieves the lowest value of the scope for which the
* attribute is defined.
@@ -72,7 +72,7 @@
* @throws IllegalArgumentException if name is empty.
*/
public int getAttributesScope(String name);
-
+
/**
* Retrieves the Bindings instance associated with the gieve
* scope. Returns null if no namespace is assoicited with
@@ -84,7 +84,7 @@
* If no Bindings is defined for the specified scope value in ScriptContext of this type.
*/
public Bindings getBindings(int scope);
-
+
/**
* Retrieves an instance of java.io.Writer which can be used by
* scripts to display their output.
@@ -92,7 +92,7 @@
* @return an instance of java.io.Writer
*/
public Writer getWriter();
-
+
/**
* Returns the Writer to be used to display error output.
* @return the error writer
@@ -141,37 +141,37 @@
* scope is invalid
*/
public Object removeAttribute(String name, int scope);
-
+
/**
- * Associates a specified value with the specifed name in the
+ * Associates a specified value with the specifed name in the
* specified scope.
- *
- * @param key the name of the attribute
- * @param value the value of the attribute
- * @param scope the level of the scope
+ *
+ * @param key the name of the attribute
+ * @param value the value of the attribute
+ * @param scope the level of the scope
* @throws IllegalArgumentException if the name is null or the
* scope is invalid
* @throws NullPointerException if the name is null.
- */
- public void setAttribute(String key,Object value,int scope);
-
- /**
- * Associates the specified Bindings with the specified scope.
+ */
+ public void setAttribute(String key,Object value,int scope);
+
+ /**
+ * Associates the specified Bindings with the specified scope.
*
- * @param bindings the Bindings to be associated with the
+ * @param bindings the Bindings to be associated with the
* specified level of scope
- * @param scope the scope
+ * @param scope the scope
* @throws IllegalArgumentException if the scope is invalid
* @throws NullPointerException if the bindings is null and the
* scope is ScriptEngine.ENGINE_SCOPE
- */
- public void setBindings(Bindings bindings,int scope);
-
- /**
- * Returns immutable List of all the valid values for scope in the ScriptContext.
- *
- * @return the list
- */
- public List getScopes();
-
+ */
+ public void setBindings(Bindings bindings,int scope);
+
+ /**
+ * Returns immutable List of all the valid values for scope in the ScriptContext.
+ *
+ * @return the list
+ */
+ public List getScopes();
+
}
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngine.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngine.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngine.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngine.java Wed Mar 25 00:21:52 2009
@@ -25,49 +25,49 @@
* See Javadoc of <a href="http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html">Java Scripting API</a>
*/
public interface ScriptEngine {
-
+
/**
* Reserved key associated with an object array which is used to
* pass set of positional parameters to the ScriptEngines.
*/
public static final String ARGV="javax.script.argv";
-
+
/**
* Reserved key associated with name of the file which contains
* the source of the script.
*/
- public static final String FILENAME = "javax.script.filename";
-
- /**
+ public static final String FILENAME = "javax.script.filename";
+
+ /**
* Reserved key associated with the name of the Java
* ScriptEngine
- */
- public static final String ENGINE = "javax.script.engine";
-
- /**
+ */
+ public static final String ENGINE = "javax.script.engine";
+
+ /**
* Reserved key associated with the version of the Java
* ScriptEngine
*/
- public static final String ENGINE_VERSION = "javax.script.engine_version";
-
- /**
+ public static final String ENGINE_VERSION = "javax.script.engine_version";
+
+ /**
* Reserved key associated with the name of the supported
* scripting language
*/
- public static final String LANGUAGE = "javax.script.language";
-
- /**
+ public static final String LANGUAGE = "javax.script.language";
+
+ /**
* Reserved key associated with the version of the supported
* scripting language
*/
- public static final String LANGUAGE_VERSION = "javax.script.language_version";
-
+ public static final String LANGUAGE_VERSION = "javax.script.language_version";
+
/**
* Reserved key associated with the named value which identifies
* the short name of the supported language
*/
public static final String NAME = "javax.script.name";
-
+
/**
* Retrieves an uninitailized Bindings which can be used as the scope of
* the ScriptEngine.
@@ -76,7 +76,7 @@
* of the ScriptEngine
*/
public Bindings createBindings();
-
+
/**
* Evaluates a piece of script obtained using the specified
* reader as the script source. Returns null for non-returning
@@ -88,7 +88,7 @@
* @throws NullPointerException if argument is null
*/
public Object eval(Reader reader) throws ScriptException;
-
+
/**
* Evaluates a piece of scripts obtained using a reader as the
* script source and using the specified namespace as the
@@ -102,7 +102,7 @@
*/
public Object eval(Reader reader, Bindings bindings)
throws ScriptException;
-
+
/**
* Evaluates a script obtained using the specified reader as the
* script source and using the namespaces in the specifed
@@ -117,18 +117,18 @@
*/
public Object eval(Reader reader, ScriptContext context)
throws ScriptException;
-
+
/**
* Evaluates a piece of script and returns the resultant object.
* Returns null for non-returning scripts.
*
- * @param script the String representation of the script
- * @return the value of the evaluated script
- * @throws ScriptException if an error occurs
- * @throws NullPointerException if argument is null
- */
+ * @param script the String representation of the script
+ * @return the value of the evaluated script
+ * @throws ScriptException if an error occurs
+ * @throws NullPointerException if argument is null
+ */
public Object eval(String script) throws ScriptException;
-
+
/**
* Evaluates a piece of script using the specified namespace as
* the SCRIPT_SCOPE. Retruns null for non-returning scripts.
@@ -139,9 +139,9 @@
* @throws ScriptException if an error occurs
* @throws NullPointerException if either argument is null
*/
- public Object eval(String script ,Bindings bindings)
+ public Object eval(String script ,Bindings bindings)
throws ScriptException;
-
+
/**
* Evaluates a script using the namespaces in the specifed
* ScriptContext. Return null for non-returning scripts.
@@ -153,9 +153,9 @@
* @throws ScriptException if an error occurs
* @throws NullPointerException if either argument is null
*/
- public Object eval(String script, ScriptContext context)
+ public Object eval(String script, ScriptContext context)
throws ScriptException;
-
+
/**
* Retrieves the value which is associated with the specified key
* in the state of the ScriptEngine.
@@ -166,7 +166,7 @@
* @throws NullPointerException if argument is null
*/
public Object get(String key);
-
+
/**
* Retrieves a ScriptEngineFactory for the class to which
* describes the underlying ScriptEngine.
@@ -175,7 +175,7 @@
* underlying ScriptEngine
*/
public ScriptEngineFactory getFactory();
-
+
/**
* Retrieves a reference to the associated bindings for the
* specified level of scope.
@@ -196,7 +196,7 @@
* @throws IllegalArgumentException if the scope is invalid
*/
public Bindings getBindings(int scope);
-
+
/**
* Associates a key and a value in the ScriptEngine namespace.
*
@@ -205,9 +205,9 @@
* specified key
* @throws IllegalArgumentException if the key is empty
* @throws NullPointerException if key is null
- */
- public void put(String key, Object value);
-
+ */
+ public void put(String key, Object value);
+
/**
* Associates the specified namespace with the specified level of
* scope.
@@ -221,8 +221,8 @@
* @throws NullPointerException
* if the bindings is null and the scope is ScriptContext.ENGINE_SCOPE
*/
- public void setBindings(Bindings bindings, int scope);
-
+ public void setBindings(Bindings bindings, int scope);
+
/**
* Returns the default ScriptContext of the ScriptEngine whose Bindings, Readers
* and Writers are used for script executions when no ScriptContext is specified.
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineFactory.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineFactory.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineFactory.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineFactory.java Wed Mar 25 00:21:52 2009
@@ -25,7 +25,7 @@
* See Javadoc of <a href="http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html">Java Scripting API</a>
*/
public interface ScriptEngineFactory {
-
+
/**
* Retrieves an instance of the associated ScriptEngine.
*
@@ -33,75 +33,75 @@
*/
public ScriptEngine getScriptEngine();
- /**
+ /**
* Retrieves the full name of the ScriptEngine.
*
- * @return the name of the Script Engine
- */
- public String getEngineName();
-
- /**
+ * @return the name of the Script Engine
+ */
+ public String getEngineName();
+
+ /**
* Retrieves the version of the Script Engine.
*
- * @return the version of the Script Engine
- */
+ * @return the version of the Script Engine
+ */
public String getEngineVersion();
-
- /**
+
+ /**
* Retrieves the name of the language supported by the
* ScriptEngine.
*
- * @return the name of the supported language
- */
- public String getLanguageName();
-
+ * @return the name of the supported language
+ */
+ public String getLanguageName();
+
/**
* Retrieves the version of the language supported by the
* ScriptEngine.
*
* @return the version of the supported language
*/
- public String getLanguageVersion();
-
- /**
+ public String getLanguageVersion();
+
+ /**
* Retrieves an immutable list of Strings which are file extensions
* typically used for files containing scripts written in the
* language supported by the ScriptEngine.
*
- * @return immutable list of supported file extensions
- */
- public List getExtensions();
-
+ * @return immutable list of supported file extensions
+ */
+ public List getExtensions();
+
/**
* Retrieves an immutable list of Strings containing MIME types describing
* the content which can be processed using the Script Engine.
*
- * @return immutable list of MIME types
- */
- public List getMimeTypes();
-
- /**
+ * @return immutable list of MIME types
+ */
+ public List getMimeTypes();
+
+ /**
* Retrieves an immutable list of short descriptive names such as
* {"javascript", "rhino"} describing the language supported by
* the Script Engine.
*
- * @return immutable list of short descriptive names describing the
+ * @return immutable list of short descriptive names describing the
* language supported by the ScriptEngine
- */
- public List getNames();
-
- /**
+ */
+ public List getNames();
+
+ /**
* Retrieves an associated value for the specified key. Returns
* null if the ScriptEngine does not have an associated value for
* the key.
*
* @return associated value for the specified key
- */
- public Object getParameter(String key);
+ */
+ public Object getParameter(String key);
+
+ public String getMethodCallSyntax(String obj, String method, String[] args);
+
+ public String getOutputStatement(String toDisplay);
- public String getMethodCallSyntax(String obj, String method, String[] args);
-
- public String getOutputStatement(String toDisplay);
-
- public String getProgram(String[] statements);
+ public String getProgram(String[] statements);
}
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java Wed Mar 25 00:21:52 2009
@@ -33,40 +33,40 @@
*/
public class ScriptEngineManager {
- /** Stores all instances of classes which implements
+ /** Stores all instances of classes which implements
* ScriptEngineFactory which are found in resources
* META-INF/services/javax.script.ScriptEngineFactory
*/
private final HashSet engineSpis = new HashSet();
-
+
/**
* Stores language names with an associated
* ScriptEngineFactory
*/
private final HashMap nameAssociations = new HashMap();
-
+
/**
* Stores file extensions with an associated
* ScriptEngineFactory
*/
private final HashMap extensionAssocitions = new HashMap();
-
+
/** Stores MIME types with an associated ScriptEngineFactory */
private final HashMap mimeTypeAssociations = new HashMap();
-
+
/** Stores the namespace associated with GLOBAL_SCOPE */
private Bindings globalscope = new SimpleBindings();
-
+
/**
* Constructs ScriptEngineManager and initializes it.
*/
- public ScriptEngineManager() {
+ public ScriptEngineManager() {
this(Thread.currentThread().getContextClassLoader());
- }
-
+ }
+
public ScriptEngineManager(ClassLoader loader) {
Iterator iterator = ServiceRegistry.lookupProviders(ScriptEngineFactory.class, loader);
-
+
while (iterator.hasNext()) {
ScriptEngineFactory factory;
try {
@@ -75,7 +75,7 @@
continue;
}
engineSpis.add(factory);
-
+
List data = factory.getNames();
// gets all descriptinve names for Scripting Engine
for (int i=0; i<data.size(); i++) {
@@ -92,7 +92,7 @@
mimeTypeAssociations.put(data.get(i), factory);
}
}
-
+
initXMLHelper(loader);
}
@@ -101,16 +101,16 @@
* (Temporary approach for beta2 release)
*/
private void initXMLHelper(ClassLoader loader) {
- try {
- Class xmlHelperClass = Class.forName("org.apache.bsf.xml.XMLHelper", true, loader);
- Method initMethod = xmlHelperClass.getMethod("init", new Class[]{});
- initMethod.invoke(null, new Object[]{});
- } catch (Throwable e) {
- // ignore
- }
- }
+ try {
+ Class xmlHelperClass = Class.forName("org.apache.bsf.xml.XMLHelper", true, loader);
+ Method initMethod = xmlHelperClass.getMethod("init", new Class[]{});
+ initMethod.invoke(null, new Object[]{});
+ } catch (Throwable e) {
+ // ignore
+ }
+ }
- /**
+ /**
* Retrieves the associated value for the spefied key in the
* GLOBAL_SCOPE
*
@@ -122,56 +122,56 @@
return globalscope.get(key);
}
- /**
+ /**
* Retrieves a new instance of a ScriptingEngine for the
* specified extension of a scirpt file. Returns null if no
* suitable ScriptingEngine is found.
*
- * @param extension the specified extension of a script file
- * @return a new instance of a ScriptingEngine which supports the
+ * @param extension the specified extension of a script file
+ * @return a new instance of a ScriptingEngine which supports the
* specified script file extension
- */
+ */
public ScriptEngine getEngineByExtension(String extension){
-
+
ScriptEngine engine = null;
-
+
ScriptEngineFactory factory =
(ScriptEngineFactory) extensionAssocitions.get(extension);
-
- if (factory != null) {
+
+ if (factory != null) {
// gets a new instance of the Scripting Engine
- engine = factory.getScriptEngine();
+ engine = factory.getScriptEngine();
// sets the GLOBAL SCOPE
- engine.setBindings(globalscope,ScriptContext.GLOBAL_SCOPE);
+ engine.setBindings(globalscope,ScriptContext.GLOBAL_SCOPE);
}
-
- return engine;
- }
-
- /**
+
+ return engine;
+ }
+
+ /**
* Retrieves new instance the ScriptingEngine for a specifed MIME
* type. Returns null if no suitable ScriptingEngine is found.
*
- * @param mimeType the specified MIME type
- * @return a new instance of a ScriptingEngine which supports the
+ * @param mimeType the specified MIME type
+ * @return a new instance of a ScriptingEngine which supports the
* specified MIME type
- */
+ */
public ScriptEngine getEngineByMimeType(String mimeType){
-
+
ScriptEngine engine = null;
- ScriptEngineFactory factory =
+ ScriptEngineFactory factory =
(ScriptEngineFactory) mimeTypeAssociations.get(mimeType);
-
- if (factory != null) {
- // gets a new instance of the Scripting Engine
+
+ if (factory != null) {
+ // gets a new instance of the Scripting Engine
engine = factory.getScriptEngine();
// sets the GLOBAL SCOPE
- engine.setBindings(globalscope,ScriptContext.GLOBAL_SCOPE);
+ engine.setBindings(globalscope,ScriptContext.GLOBAL_SCOPE);
}
-
- return engine;
- }
-
+
+ return engine;
+ }
+
/**
* Retrieves a new instance of a ScriptEngine the specified
* descriptieve name. Returns null if no suitable ScriptEngine is
@@ -181,20 +181,20 @@
* @return a new instance of a ScriptEngine which supports the
* specifed descriptive name
*/
- public ScriptEngine getEngineByName(String name){
-
+ public ScriptEngine getEngineByName(String name){
+
ScriptEngine engine = null;
ScriptEngineFactory factory =
(ScriptEngineFactory) nameAssociations.get(name);
-
- if (factory != null) {
+
+ if (factory != null) {
engine = factory.getScriptEngine();
- engine.setBindings(globalscope,ScriptContext.GLOBAL_SCOPE);
- }
-
- return engine;
- }
-
+ engine.setBindings(globalscope,ScriptContext.GLOBAL_SCOPE);
+ }
+
+ return engine;
+ }
+
/**
* Retrieves an array of instances of ScriptEngineFactory class
* which are found by the discovery mechanism.
@@ -203,15 +203,15 @@
* instances
*/
public List getEngineFactories(){
- ArrayList factories = new ArrayList();
- Iterator iter = engineSpis.iterator();
-
- while(iter.hasNext()) {
- factories.add(iter.next());
- }
- return factories;
+ ArrayList factories = new ArrayList();
+ Iterator iter = engineSpis.iterator();
+
+ while(iter.hasNext()) {
+ factories.add(iter.next());
+ }
+ return factories;
}
-
+
/**
* Retrieves the bindings corresponds to GLOBAL_SCOPE.
*
@@ -220,7 +220,7 @@
public Bindings getBindings(){
return globalscope;
}
-
+
/**
* Associates the specifed value with the specified key in
* GLOBAL_SCOPE.
@@ -240,7 +240,7 @@
}
globalscope.put(key, value);
}
-
+
/**
* Register a extension with a ScriptEngineFactory. It
* overrides any such association discovered previously.
@@ -253,7 +253,7 @@
public void registerEngineExtension(String extension, ScriptEngineFactory factory){
extensionAssocitions.put(extension, factory);
}
-
+
/**
* Registers descriptive name with a ScriptEngineFactory.
* It overrides any associations discovered previously.
@@ -266,7 +266,7 @@
public void registerEngineName(String name, ScriptEngineFactory factory){
nameAssociations.put(name, factory);
}
-
+
/**
* Registers a MIME type with a ScriptEngineFactory. It
* overrides any associations discovered previously.
@@ -276,20 +276,20 @@
* @param factory the ScriptEngineFactory associated with the
* specified MIME type
*/
- public void registerEngineMimeType(String mimeType,ScriptEngineFactory factory){
- mimeTypeAssociations.put(mimeType,factory);
- }
-
+ public void registerEngineMimeType(String mimeType,ScriptEngineFactory factory){
+ mimeTypeAssociations.put(mimeType,factory);
+ }
+
/**
* Sets the GLOBAL_SCOPE value to the specified namespace.
*
* @param bindings the namespace to be stored in GLOBAL_SCOPE
* @throws IllegalArgumentException if bindings is null
*/
- public void setBindings(Bindings bindings){
- if (bindings == null){
- throw new IllegalArgumentException("bindings must not be null");
- }
- globalscope = bindings;
- }
+ public void setBindings(Bindings bindings){
+ if (bindings == null){
+ throw new IllegalArgumentException("bindings must not be null");
+ }
+ globalscope = bindings;
+ }
}
\ No newline at end of file
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptException.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptException.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptException.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptException.java Wed Mar 25 00:21:52 2009
@@ -24,40 +24,40 @@
*/
//@Immutable
public class ScriptException extends Exception {
-
- private static final long serialVersionUID = 1L;
- /** Stores the file name of the script */
- private final String fileName; // default null
-
+ private static final long serialVersionUID = 1L;
+
+ /** Stores the file name of the script */
+ private final String fileName; // default null
+
/**
* Stores the line number of the script in which the error has
* occured
*/
- private final int lineNumber; // default = -1;
-
+ private final int lineNumber; // default = -1;
+
/**
* Stores the column number of the script in which the error has
* occured
*/
- private final int columnNumber; // default = -1;
-
+ private final int columnNumber; // default = -1;
+
/** Stores the message which describes the cause of error */
- private final String message; // default null
-
+ private final String message; // default null
+
/**
* Constructs a new exception with the specified cause.
*
* @param exception the cause of exception
*/
- public ScriptException(Exception exception) {
- super(exception);
+ public ScriptException(Exception exception) {
+ super(exception);
this.message = null;
this.fileName = null;
this.lineNumber = -1;
this.columnNumber = -1;
- }
-
+ }
+
/**
* Constructs a new exception with the specified detailed
* message.
@@ -81,8 +81,8 @@
*/
public ScriptException(String message,String fileName,int lineNumber) {
this(message, fileName, lineNumber, -1);
- }
-
+ }
+
/**
* Constructs a new exception using the detailed message of
* cause, file name which contains the script, line number and
@@ -97,15 +97,15 @@
* @param columnNumber the column number of the script where the
* error has occured
*/
- public ScriptException(String message, String fileName, int lineNumber, int columnNumber) {
- super(message);
+ public ScriptException(String message, String fileName, int lineNumber, int columnNumber) {
+ super(message);
this.message = message;
- this.fileName = fileName;
- this.lineNumber = lineNumber;
- this.columnNumber = columnNumber;
- }
-
- /**
+ this.fileName = fileName;
+ this.lineNumber = lineNumber;
+ this.columnNumber = columnNumber;
+ }
+
+ /**
* Retrieves the file name in which the script is contained.
*
* @return Returns the file name in which the script is contained
@@ -113,29 +113,29 @@
public String getFileName() {
return fileName;
}
-
- /**
+
+ /**
* Retrieves the column number of the script where the error has
* occured. If the information is not available, returns -1.
*
- * @return Returns the column number of the script where the
+ * @return Returns the column number of the script where the
* error has occured
- */
- public int getColumnNumber() {
- return columnNumber;
- }
-
- /**
+ */
+ public int getColumnNumber() {
+ return columnNumber;
+ }
+
+ /**
* Retrieves the line number of the script where the error has
* occured. If the information is not available, returns -1.
*
- * @return Returns the line number of the script where the error
+ * @return Returns the line number of the script where the error
* has occured
- */
- public int getLineNumber() {
- return lineNumber;
- }
-
+ */
+ public int getLineNumber() {
+ return lineNumber;
+ }
+
/**
* Retrieves a String describing the cause of error.
*
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleBindings.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleBindings.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleBindings.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleBindings.java Wed Mar 25 00:21:52 2009
@@ -29,19 +29,19 @@
* See Javadoc of <a href="http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html">Java Scripting API</a>
*/
public class SimpleBindings implements Bindings {
-
- /**
+
+ /**
* In which the key-value pairs are stored.
- */
+ */
private final Map map;
-
+
/**
* Constructs a SimpleNamespace.
*/
- public SimpleBindings(){
+ public SimpleBindings(){
map = new HashMap();
- }
-
+ }
+
/**
* Constructs a SimpleNamespace and initializes it using a
* specified map.
@@ -49,34 +49,34 @@
* @param map a map which is used to initialize the
* SimpleNamespace
*/
- public SimpleBindings(Map map){
- this.map = map;
- }
-
-
-
- /**
- * Check the conditions which keys need to satisfy:
- * - String
- * - non-null
- * - non-Empty
- * @param key key to be checked
- *
- * @throws NullPointerException if key is null
+ public SimpleBindings(Map map){
+ this.map = map;
+ }
+
+
+
+ /**
+ * Check the conditions which keys need to satisfy:
+ * - String
+ * - non-null
+ * - non-Empty
+ * @param key key to be checked
+ *
+ * @throws NullPointerException if key is null
* @throws ClassCastException if key is not String
* @throws llegalArgumentException if key is empty String
- */
- private void validateKey(Object key){
- if (key == null) {
- throw new NullPointerException("key must not be null");
- }
+ */
+ private void validateKey(Object key){
+ if (key == null) {
+ throw new NullPointerException("key must not be null");
+ }
if (!(key instanceof String)) {
throw new ClassCastException("key must be a String");
}
if (((String)key).length() == 0) {
throw new IllegalArgumentException("key must not be the empty string");
}
- }
+ }
/** {@inheritDoc} */
public Object put(Object key, Object value) {
@@ -97,72 +97,72 @@
*/
public Object put(String key, Object value) {
validateKey(key);
- return map.put(key,value);
- }
-
+ return map.put(key,value);
+ }
+
/** {@inheritDoc} */
- public void putAll(Map toMerge) {
-
+ public void putAll(Map toMerge) {
+
Set keySet= toMerge.keySet();
- Iterator keys= keySet.iterator();
-
+ Iterator keys= keySet.iterator();
+
while (keys.hasNext()) {
validateKey(keys.next());
}
-
- map.putAll(toMerge);
- }
-
+
+ map.putAll(toMerge);
+ }
+
/** {@inheritDoc} */
public int size() {
return map.size();
}
-
+
/** {@inheritDoc} */
public void clear() {
map.clear();
}
-
+
/** {@inheritDoc} */
public boolean isEmpty() {
return map.isEmpty();
}
-
+
+ /** {@inheritDoc} */
+ public boolean containsKey(Object key) {
+ validateKey(key);
+ return map.containsKey(key);
+ }
/** {@inheritDoc} */
- public boolean containsKey(Object key) {
- validateKey(key);
- return map.containsKey(key);
- }
- /** {@inheritDoc} */
- public boolean containsValue(Object value) {
- return map.containsValue(value);
- }
-
+ public boolean containsValue(Object value) {
+ return map.containsValue(value);
+ }
+
/** {@inheritDoc} */
public Collection values() {
return map.values();
}
-
+
/** {@inheritDoc} */
- public Set entrySet() {
- return map.entrySet();
- }
-
+ public Set entrySet() {
+ return map.entrySet();
+ }
+
/** {@inheritDoc} */
public Object get(Object key) {
validateKey(key);
- return map.get(key);
- }
+ return map.get(key);
+ }
/** {@inheritDoc} */
- public Set keySet() {
- return map.keySet();
- }
+ public Set keySet() {
+ return map.keySet();
+ }
/** {@inheritDoc} */
public Object remove(Object key) {
validateKey(key);
- return map.remove(key);
- }
+ return map.remove(key);
+ }
}
Modified: jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleScriptContext.java
URL: http://svn.apache.org/viewvc/jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleScriptContext.java?rev=758099&r1=758098&r2=758099&view=diff
==============================================================================
--- jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleScriptContext.java (original)
+++ jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/SimpleScriptContext.java Wed Mar 25 00:21:52 2009
@@ -31,58 +31,58 @@
* See Javadoc of <a href="http://java.sun.com/javase/6/docs/api/javax/script/package-summary.html">Java Scripting API</a>
*/
public class SimpleScriptContext implements ScriptContext {
-
- /**
- * This is the scope bindings for GLOBAL_SCOPE.
- * By default, a null value (which means no global scope) is used.
- * */
+
+ /**
+ * This is the scope bindings for GLOBAL_SCOPE.
+ * By default, a null value (which means no global scope) is used.
+ * */
protected Bindings globalScope = null;
-
- /**
- * This is the scope bindings for ENGINE_SCOPE .
- * By default, a SimpleBindings is used.
- */
- protected Bindings engineScope = new SimpleBindings();
- /** The reader to be used for input from scripts. */
- protected Reader reader;
+ /**
+ * This is the scope bindings for ENGINE_SCOPE .
+ * By default, a SimpleBindings is used.
+ */
+ protected Bindings engineScope = new SimpleBindings();
+
+ /** The reader to be used for input from scripts. */
+ protected Reader reader;
- /** The writer to be used for displaying output from scripts */
- protected Writer writer;
+ /** The writer to be used for displaying output from scripts */
+ protected Writer writer;
/** The writer to be used for displaying error output from scripts */
- protected Writer errorWriter;
+ protected Writer errorWriter;
+
+ private static final List SCOPES =
+ Collections.unmodifiableList(
+ Arrays.asList(new Integer[] { new Integer(ENGINE_SCOPE), new Integer(GLOBAL_SCOPE) })
+ );
- private static final List SCOPES =
- Collections.unmodifiableList(
- Arrays.asList(new Integer[] { new Integer(ENGINE_SCOPE), new Integer(GLOBAL_SCOPE) })
- );
-
- public SimpleScriptContext() {
+ public SimpleScriptContext() {
reader = new InputStreamReader(System.in);
writer = new PrintWriter(System.out, true);
errorWriter = new PrintWriter(System.err, true);
- }
-
- /**
- * Check if name is null or empty string
- * @param name to be checked
- */
- private void checkName(String name){
- if (name == null){
- throw new NullPointerException("name must not be null");
- }
- if (name.length() == 0){
- throw new IllegalArgumentException("name must not be an empty string");
- }
- }
-
+ }
+
+ /**
+ * Check if name is null or empty string
+ * @param name to be checked
+ */
+ private void checkName(String name){
+ if (name == null){
+ throw new NullPointerException("name must not be null");
+ }
+ if (name.length() == 0){
+ throw new IllegalArgumentException("name must not be an empty string");
+ }
+ }
- /** {@inheritDoc} */
- public Object getAttribute(String name) {
- checkName(name);
-
+ /** {@inheritDoc} */
+ public Object getAttribute(String name) {
+
+ checkName(name);
+
if (engineScope.get(name) != null) {
return engineScope.get(name);
} else if (globalScope != null && globalScope.get(name) != null) {
@@ -91,25 +91,25 @@
return null;
}
}
-
+
/** {@inheritDoc} */
public Object getAttribute(String name, int scope) {
-
+
checkName(name);
-
+
switch (scope) {
- case ENGINE_SCOPE:
- return engineScope.get(name);
- case GLOBAL_SCOPE:
- return globalScope != null ? globalScope.get(name) : null;
- default:
- throw new IllegalArgumentException("invalid scope");
+ case ENGINE_SCOPE:
+ return engineScope.get(name);
+ case GLOBAL_SCOPE:
+ return globalScope != null ? globalScope.get(name) : null;
+ default:
+ throw new IllegalArgumentException("invalid scope");
}
}
/** {@inheritDoc} */
public int getAttributesScope(String name) {
-
+
checkName(name);
if (engineScope.containsKey(name)) {
@@ -117,110 +117,110 @@
} else if(globalScope != null && globalScope.containsKey(name)) {
return GLOBAL_SCOPE;
}
-
+
return -1;
}
-
+
/** {@inheritDoc} */
public Bindings getBindings(int scope) {
-
- switch (scope) {
- case ENGINE_SCOPE:
- return engineScope;
- case GLOBAL_SCOPE:
- return globalScope;
- default:
- throw new IllegalArgumentException("invalid scope");
+
+ switch (scope) {
+ case ENGINE_SCOPE:
+ return engineScope;
+ case GLOBAL_SCOPE:
+ return globalScope;
+ default:
+ throw new IllegalArgumentException("invalid scope");
}
}
-
+
/** {@inheritDoc} */
public Object removeAttribute(String name, int scope) {
-
+
checkName(name);
-
+
switch (scope) {
- case ENGINE_SCOPE:
- return engineScope.remove(name);
- case GLOBAL_SCOPE:
- return globalScope != null ? globalScope.remove(name) : null;
- default:
- throw new IllegalArgumentException("invalid scope");
+ case ENGINE_SCOPE:
+ return engineScope.remove(name);
+ case GLOBAL_SCOPE:
+ return globalScope != null ? globalScope.remove(name) : null;
+ default:
+ throw new IllegalArgumentException("invalid scope");
}
}
-
+
/** {@inheritDoc} */
public void setAttribute(String name, Object value, int scope) {
-
+
checkName(name);
-
+
+ switch (scope) {
+ case ENGINE_SCOPE:
+ engineScope.put(name, value);
+ break;
+ case GLOBAL_SCOPE:
+ if (globalScope != null) {
+ globalScope.put(name, value);
+ } else {
+ throw new IllegalArgumentException("Global scope is null");// TODO is this correct?
+ }
+ break;
+ default:
+ throw new IllegalArgumentException("invalid scope");
+ }
+ }
+
+ /** {@inheritDoc} */
+ public void setBindings(Bindings namespace, int scope) {
+
switch (scope) {
- case ENGINE_SCOPE:
- engineScope.put(name, value);
- break;
- case GLOBAL_SCOPE:
- if (globalScope != null) {
- globalScope.put(name, value);
- } else {
- throw new IllegalArgumentException("Global scope is null");// TODO is this correct?
- }
- break;
- default:
- throw new IllegalArgumentException("invalid scope");
- }
- }
-
- /** {@inheritDoc} */
- public void setBindings(Bindings namespace, int scope) {
-
- switch (scope) {
- case ENGINE_SCOPE:
+ case ENGINE_SCOPE:
if (namespace == null) {
throw new NullPointerException("binding is null for ENGINE_SCOPE scope");
}
- engineScope = namespace;
- break;
- case GLOBAL_SCOPE:
- globalScope = namespace;
- break;
- default:
- throw new IllegalArgumentException("invalid scope");
- }
+ engineScope = namespace;
+ break;
+ case GLOBAL_SCOPE:
+ globalScope = namespace;
+ break;
+ default:
+ throw new IllegalArgumentException("invalid scope");
+ }
}
/** {@inheritDoc} */
- public List getScopes() {
- return SCOPES;
- }
+ public List getScopes() {
+ return SCOPES;
+ }
/** {@inheritDoc} */
- public Reader getReader() {
- return reader;
- }
+ public Reader getReader() {
+ return reader;
+ }
/** {@inheritDoc} */
- public void setReader(Reader reader) {
- this.reader = reader;
- }
+ public void setReader(Reader reader) {
+ this.reader = reader;
+ }
/** {@inheritDoc} */
- public Writer getWriter() {
- return writer;
- }
+ public Writer getWriter() {
+ return writer;
+ }
/** {@inheritDoc} */
- public void setWriter(Writer writer) {
- this.writer = writer;
- }
+ public void setWriter(Writer writer) {
+ this.writer = writer;
+ }
/** {@inheritDoc} */
- public Writer getErrorWriter() {
- return errorWriter;
- }
+ public Writer getErrorWriter() {
+ return errorWriter;
+ }
/** {@inheritDoc} */
- public void setErrorWriter(Writer writer) {
- this.errorWriter = writer;
- }
+ public void setErrorWriter(Writer writer) {
+ this.errorWriter = writer;
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-dev-help@jakarta.apache.org