KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > test > SpecialSeq


1 /*
2  * Copyright 2003-2004 Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17 package test;
18
19 import org.apache.tools.ant.Task;
20 import org.apache.tools.ant.TaskContainer;
21 import org.apache.tools.ant.BuildException;
22 import org.apache.tools.ant.types.FileSet;
23 import org.apache.tools.ant.taskdefs.Echo;
24 import java.util.*;
25
26 public class SpecialSeq extends Task implements TaskContainer {
27     /** Optional Vector holding the nested tasks */
28     private Vector nestedTasks = new Vector();
29
30     private FileSet fileset;
31     
32     private Echo nestedEcho;
33     
34     /**
35      * Add a nested task.
36      * <p>
37      * @param nestedTask Nested task to execute
38      * <p>
39      */

40     public void addTask(Task nestedTask) {
41         nestedTasks.addElement(nestedTask);
42     }
43
44     /**
45      * Execute all nestedTasks.
46      */

47     public void execute() throws BuildException {
48         if (fileset == null || fileset.getDir(getProject()) == null) {
49             throw new BuildException("Fileset was not configured");
50         }
51         for (Enumeration e = nestedTasks.elements(); e.hasMoreElements();) {
52             Task nestedTask = (Task) e.nextElement();
53             nestedTask.perform();
54         }
55         nestedEcho.reconfigure();
56         nestedEcho.perform();
57     }
58
59     public void addFileset(FileSet fileset) {
60         this.fileset = fileset;
61     }
62     
63     public void addNested(Echo nestedEcho) {
64         this.nestedEcho = nestedEcho;
65     }
66 }
67
Popular Tags