You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by pe...@apache.org on 2006/12/07 22:48:59 UTC

svn commit: r483681 - /ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java

Author: peterreilly
Date: Thu Dec  7 13:48:57 2006
New Revision: 483681

URL: http://svn.apache.org/viewvc?view=rev&rev=483681
Log:
align script implementation

Modified:
    ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java

Modified: ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java
URL: http://svn.apache.org/viewvc/ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java?view=diff&rev=483681&r1=483680&r2=483681
==============================================================================
--- ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java (original)
+++ ant/core/trunk/src/main/org/apache/tools/ant/types/optional/ScriptFilter.java Thu Dec  7 13:48:57 2006
@@ -21,6 +21,9 @@
 import org.apache.tools.ant.filters.TokenFilter;
 import java.io.File;
 import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Project;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
 import org.apache.tools.ant.util.ScriptRunnerBase;
 import org.apache.tools.ant.util.ScriptRunnerHelper;
 
@@ -36,12 +39,23 @@
  * @since Ant 1.6
  */
 public class ScriptFilter extends TokenFilter.ChainableReaderFilter {
-    /** Has this object been initialized ? */
-    private boolean initialized = false;
+    /** script runner helper */
+    private ScriptRunnerHelper helper = new ScriptRunnerHelper();
+
+    /** script runner. */
+    private ScriptRunnerBase   runner = null;
+
     /** the token used by the script */
     private String token;
 
-    private ScriptRunnerHelper runner = new ScriptRunnerHelper();
+    /**
+     * Set the project.
+     * @param project the owner of this component.
+     */
+    public void setProject(Project project) {
+        super.setProject(project);
+        helper.setProjectComponent(this);
+    }
 
     /**
      * Defines the language (required).
@@ -49,7 +63,7 @@
      * @param language the scripting language name for the script.
      */
     public void setLanguage(String language) {
-        runner.setLanguage(language);
+        helper.setLanguage(language);
     }
 
     /**
@@ -58,10 +72,10 @@
      * @exception BuildException if someting goes wrong
      */
     private void init() throws BuildException {
-        if (initialized) {
+        if (runner != null) {
             return;
         }
-        initialized = true;
+        runner = helper.getScriptRunner();
     }
 
     /**
@@ -93,9 +107,7 @@
     public String filter(String token) {
         init();
         setToken(token);
-        ScriptRunnerBase srb = runner.getScriptRunner();
-        srb.bindToComponent(this);
-        srb.executeScript("ant_filter");
+        runner.executeScript("ant_filter");
         return getToken();
     }
 
@@ -105,7 +117,7 @@
      * @param file the file containing the script source.
      */
     public void setSrc(File file) {
-        runner.setSrc(file);
+        helper.setSrc(file);
     }
 
     /**
@@ -114,6 +126,43 @@
      * @param text a component of the script text to be added.
      */
     public void addText(String text) {
-        runner.addText(text);
+        helper.addText(text);
     }
+
+    /**
+     * Defines the manager.
+     *
+     * @param manager the scripting manager.
+     */
+    public void setManager(String manager) {
+        helper.setManager(manager);
+    }
+    /**
+     * Set the classpath to be used when searching for classes and resources.
+     *
+     * @param classpath an Ant Path object containing the search path.
+     */
+    public void setClasspath(Path classpath) {
+        helper.setClasspath(classpath);
+    }
+
+    /**
+     * Classpath to be used when searching for classes and resources.
+     *
+     * @return an empty Path instance to be configured by Ant.
+     */
+    public Path createClasspath() {
+        return helper.createClasspath();
+    }
+
+    /**
+     * Set the classpath by reference.
+     *
+     * @param r a Reference to a Path instance to be used as the classpath
+     *          value.
+     */
+    public void setClasspathRef(Reference r) {
+        helper.setClasspathRef(r);
+    }
+
 }



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