You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by mb...@apache.org on 2007/06/28 14:59:55 UTC

svn commit: r551543 - in /ant/core/trunk/src/main/org/apache/tools/ant/util: ScriptRunnerBase.java optional/JavaxScriptRunner.java optional/ScriptRunner.java

Author: mbenson
Date: Thu Jun 28 05:59:54 2007
New Revision: 551543

URL: http://svn.apache.org/viewvc?view=rev&rev=551543
Log:
javadoc/fmting/refactor

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
    ant/core/trunk/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java?view=diff&rev=551543&r1=551542&r2=551543
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/ScriptRunnerBase.java Thu Jun 28 05:59:54 2007
@@ -117,10 +117,10 @@
     public abstract void executeScript(String execName);
 
     /**
-     * Evalulate the script.
-     * @param execName the name that will be passed to BSF for this script
-     *        execution.
-     * @return the result of evalulating the script.
+     * Evaluate the script.
+     * @param execName the name that will be passed to the
+     *                 scripting engine for this script execution.
+     * @return the result of evaluating the script.
      */
     public abstract Object evaluateScript(String execName);
 

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java?view=diff&rev=551543&r1=551542&r2=551543
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java Thu Jun 28 05:59:54 2007
@@ -74,8 +74,8 @@
      *
      * @param execName the name that will be passed to the
      *                 scripting engine for this script execution.
-     * @return the result of the evalulation
-     * @exception BuildException if someting goes wrong exectuing the script.
+     * @return the result of the evaluation
+     * @exception BuildException if something goes wrong executing the script.
      */
     public Object evaluateScript(String execName) throws BuildException {
         checkLanguage();

Modified: ant/core/trunk/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java?view=diff&rev=551543&r1=551542&r2=551543
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/util/optional/ScriptRunner.java Thu Jun 28 05:59:54 2007
@@ -21,7 +21,6 @@
 import org.apache.bsf.BSFManager;
 import org.apache.bsf.BSFEngine;
 
-
 import java.util.Iterator;
 import java.util.Hashtable;
 
@@ -87,10 +86,8 @@
     /**
      * Do the work.
      *
-     * @param execName the name that will be passed to BSF for this script
-     *        execution.
-     *
-     * @exception BuildException if someting goes wrong exectuing the script.
+     * @param execName the name that will be passed to BSF for this script execution.
+     * @exception BuildException if something goes wrong executing the script.
      */
     public void executeScript(String execName) throws BuildException {
         checkLanguage();
@@ -105,22 +102,20 @@
                 engine.exec(execName, 0, 0, getScript());
             }
         } catch (BSFException be) {
-            throwBuildException(be);
+            throw getBuildException(be);
         } finally {
             restoreContextLoader(origLoader);
         }
     }
 
     /**
-     * Do the work.
+     * Evaluate the script.
      *
-     * @param execName the name that will be passed to BSF for this script
-     *        execution.
-     * @return the result of the evalulation
-     * @exception BuildException if someting goes wrong exectuing the script.
+     * @param execName the name that will be passed to BSF for this script execution.
+     * @return the result of the evaluation
+     * @exception BuildException if something goes wrong executing the script.
      */
-    public Object evaluateScript(String execName)
-        throws BuildException {
+    public Object evaluateScript(String execName) throws BuildException {
         checkLanguage();
         ClassLoader origLoader = replaceContextLoader();
         try {
@@ -129,34 +124,27 @@
             // execute the script
             if (engine == null) {
                 return m.eval(getLanguage(), execName, 0, 0, getScript());
-            } else {
-                return engine.eval(execName, 0, 0, getScript());
             }
+            return engine.eval(execName, 0, 0, getScript());
         } catch (BSFException be) {
-            throwBuildException(be);
-            // NotReached
-            return null;
+            throw getBuildException(be);
         } finally {
             restoreContextLoader(origLoader);
         }
     }
 
     /**
-     * Throw a buildException in place of a BSFException.
+     * Get/create a BuildException from a BSFException.
      * @param be BSFException to convert.
-     * @throws BuildException the conveted exception.
+     * @return BuildException the converted exception.
      */
-    private void throwBuildException(BSFException be) {
+    private BuildException getBuildException(BSFException be) {
         Throwable t = be;
         Throwable te = be.getTargetException();
-        if (te != null) {
-            if  (te instanceof BuildException) {
-                throw (BuildException) te;
-            } else {
-                t = te;
-            }
+        if (te instanceof BuildException) {
+            return (BuildException) te;
         }
-        throw new BuildException(t);
+        return new BuildException(te == null ? t : te);
     }
 
     private void declareBeans(BSFManager m) throws BSFException {



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