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 17:42:51 UTC

svn commit: r758339 - /jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java

Author: sebb
Date: Wed Mar 25 16:42:43 2009
New Revision: 758339

URL: http://svn.apache.org/viewvc?rev=758339&view=rev
Log:
Null pointer checks

Modified:
    jakarta/bsf/trunk/bsf3/bsf-api/src/main/java/javax/script/ScriptEngineManager.java

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=758339&r1=758338&r2=758339&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 16:42:43 2009
@@ -53,7 +53,7 @@
     /** Maps MIME types to the associated ScriptEngineFactory */
     private final HashMap mimeTypeAssociations = new HashMap();
 
-    /** Stores the bindings associated with GLOBAL_SCOPE */
+    /** Stores the bindings associated with GLOBAL_SCOPE. Defaults to SimpleBindings. */
     private Bindings globalscope = new SimpleBindings();
 
     /**
@@ -136,9 +136,15 @@
      * @param extension the specified extension of a script file
      * @return a new instance of a ScriptingEngine which supports the
      *         specified script file extension
+     *
+     * @throws NullPointerException if extension is null
      */
     public ScriptEngine getEngineByExtension(String extension){
 
+        if (extension == null) {
+            throw new NullPointerException("extension must not be null");
+        }
+
         ScriptEngine engine = null;
 
         ScriptEngineFactory factory = 
@@ -161,9 +167,15 @@
      * @param mimeType the specified MIME type
      * @return a new instance of a ScriptingEngine which supports the
      *         specified MIME type  
+     *
+     * @throws NullPointerException if mimeType is null
      */
     public ScriptEngine getEngineByMimeType(String mimeType){
 
+        if (mimeType == null) {
+            throw new NullPointerException("mimeType must not be null");
+        }
+
         ScriptEngine engine = null;
         ScriptEngineFactory factory = 
                 (ScriptEngineFactory) mimeTypeAssociations.get(mimeType);
@@ -183,15 +195,19 @@
      * descriptive name. Returns <tt>null</tt> if no suitable ScriptEngine is
      * found.
      * 
-     * @param name the descriptive name 
+     * @param shortName the short name of the engine 
      * @return a new instance of a ScriptEngine which supports the 
-     *         specifed descriptive name
+     *         specifed name
+     * @throws NullPointerException - if shortName is null
      */
-    public ScriptEngine getEngineByName(String name){
+    public ScriptEngine getEngineByName(String shortName){
+        if (shortName == null) {
+            throw new NullPointerException("shortName must not be null");
+        }
 
         ScriptEngine engine = null;
         ScriptEngineFactory factory =
-                (ScriptEngineFactory) nameAssociations.get(name);
+                (ScriptEngineFactory) nameAssociations.get(shortName);
 
         if (factory != null) {
             engine = factory.getScriptEngine();
@@ -259,6 +275,9 @@
      * @throws NullPointerException if any of the parameters is <tt>null</tt>
      */
     public void registerEngineExtension(String extension, ScriptEngineFactory factory){
+        if (extension == null || factory == null) {
+            throw new NullPointerException("parameters must be non-null");
+        }
         extensionAssociations.put(extension, factory);        
     }
 
@@ -270,8 +289,13 @@
      *        ScriptEngineFactory class
      * @param factory the ScriptEngineFactory associated with
      *        the specified descriptive name
+     *
+     * @throws NullPointerException if any of the parameters is <tt>null</tt>
      */
     public void registerEngineName(String name, ScriptEngineFactory factory){
+        if (name == null || factory == null) {
+            throw new NullPointerException("parameters must be non-null");
+        }
         nameAssociations.put(name, factory);
     }
 
@@ -283,8 +307,13 @@
      *        ScriptEngineFactory class 
      * @param factory the ScriptEngineFactory associated with the
      *        specified MIME type
+     *
+     * @throws NullPointerException if any of the parameters is <tt>null</tt>
      */
     public void registerEngineMimeType(String mimeType,ScriptEngineFactory factory){
+        if (mimeType == null || factory == null) {
+            throw new NullPointerException("parameters must be non-null");
+        }
         mimeTypeAssociations.put(mimeType,factory);
     }
 



---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-dev-help@jakarta.apache.org