KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > groovy > util > SpoofTaskContainer


1 package groovy.util;
2
3 import org.apache.tools.ant.Task;
4 import org.apache.tools.ant.TaskContainer;
5 import org.apache.tools.ant.UnknownElement;
6 import org.apache.tools.ant.BuildException;
7
8 import java.util.List JavaDoc;
9 import java.util.ArrayList JavaDoc;
10 import java.util.Iterator JavaDoc;
11
12 public class SpoofTaskContainer extends Task implements TaskContainer {
13     private List JavaDoc tasks = new ArrayList JavaDoc();
14     static StringBuffer JavaDoc spoof = new StringBuffer JavaDoc();
15
16     public SpoofTaskContainer() {
17         super();
18         spoof("SpoofTaskContainer ctor");
19     }
20
21     static StringBuffer JavaDoc getSpoof(){
22         return spoof;
23     }
24
25     static void spoof(String JavaDoc message){
26         spoof.append(message);
27         spoof.append("\n");
28     }
29
30     public void addTask(Task task) {
31         // to work with ant 1.6
32
spoof("in addTask");
33         if (task instanceof UnknownElement) {
34             task.maybeConfigure();
35             task = ((UnknownElement) task).getTask();
36         }
37         tasks.add(task);
38     }
39
40     public void execute() throws BuildException {
41         spoof("begin SpoofTaskContainer execute");
42         for (Iterator JavaDoc iter = tasks.iterator(); iter.hasNext();) {
43             Task task = (Task) iter.next();
44             task.perform();
45         }
46         spoof("end SpoofTaskContainer execute");
47     }
48
49 }
50
Popular Tags