Browse Source

javadoc/fmting/refactor

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@551543 13f79535-47bb-0310-9956-ffa450edef68
master
Matthew Jason Benson 18 years ago
parent
commit
09ce03634e
3 changed files with 22 additions and 34 deletions
  1. +4
    -4
      src/main/org/apache/tools/ant/util/ScriptRunnerBase.java
  2. +2
    -2
      src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java
  3. +16
    -28
      src/main/org/apache/tools/ant/util/optional/ScriptRunner.java

+ 4
- 4
src/main/org/apache/tools/ant/util/ScriptRunnerBase.java View File

@@ -117,10 +117,10 @@ public abstract class ScriptRunnerBase {
public abstract void executeScript(String execName); 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); public abstract Object evaluateScript(String execName);




+ 2
- 2
src/main/org/apache/tools/ant/util/optional/JavaxScriptRunner.java View File

@@ -74,8 +74,8 @@ public class JavaxScriptRunner extends ScriptRunnerBase {
* *
* @param execName the name that will be passed to the * @param execName the name that will be passed to the
* scripting engine for this script execution. * 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 { public Object evaluateScript(String execName) throws BuildException {
checkLanguage(); checkLanguage();


+ 16
- 28
src/main/org/apache/tools/ant/util/optional/ScriptRunner.java View File

@@ -21,7 +21,6 @@ import org.apache.bsf.BSFException;
import org.apache.bsf.BSFManager; import org.apache.bsf.BSFManager;
import org.apache.bsf.BSFEngine; import org.apache.bsf.BSFEngine;



import java.util.Iterator; import java.util.Iterator;
import java.util.Hashtable; import java.util.Hashtable;


@@ -87,10 +86,8 @@ public class ScriptRunner extends ScriptRunnerBase {
/** /**
* Do the work. * 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 { public void executeScript(String execName) throws BuildException {
checkLanguage(); checkLanguage();
@@ -105,22 +102,20 @@ public class ScriptRunner extends ScriptRunnerBase {
engine.exec(execName, 0, 0, getScript()); engine.exec(execName, 0, 0, getScript());
} }
} catch (BSFException be) { } catch (BSFException be) {
throwBuildException(be);
throw getBuildException(be);
} finally { } finally {
restoreContextLoader(origLoader); 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(); checkLanguage();
ClassLoader origLoader = replaceContextLoader(); ClassLoader origLoader = replaceContextLoader();
try { try {
@@ -129,34 +124,27 @@ public class ScriptRunner extends ScriptRunnerBase {
// execute the script // execute the script
if (engine == null) { if (engine == null) {
return m.eval(getLanguage(), execName, 0, 0, getScript()); 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) { } catch (BSFException be) {
throwBuildException(be);
// NotReached
return null;
throw getBuildException(be);
} finally { } finally {
restoreContextLoader(origLoader); restoreContextLoader(origLoader);
} }
} }


/** /**
* Throw a buildException in place of a BSFException.
* Get/create a BuildException from a BSFException.
* @param be BSFException to convert. * @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 t = be;
Throwable te = be.getTargetException(); 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 { private void declareBeans(BSFManager m) throws BSFException {


Loading…
Cancel
Save