KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tools > ant > taskdefs > Sequential


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

18 package org.apache.tools.ant.taskdefs;
19
20 import java.util.Iterator JavaDoc;
21 import java.util.Vector JavaDoc;
22 import org.apache.tools.ant.BuildException;
23 import org.apache.tools.ant.Task;
24 import org.apache.tools.ant.TaskContainer;
25
26 /**
27  * Sequential is a container task - it can contain other Ant tasks. The nested
28  * tasks are simply executed in sequence. Sequential's primary use is to support
29  * the sequential execution of a subset of tasks within the {@link Parallel Parallel Task}
30
31  * <p>
32  * The sequential task has no attributes and does not support any nested
33  * elements apart from Ant tasks. Any valid Ant task may be embedded within the
34  * sequential task.</p>
35  *
36  * @since Ant 1.4
37  * @ant.task category="control"
38  */

39 public class Sequential extends Task implements TaskContainer {
40
41     /** Optional Vector holding the nested tasks */
42     private Vector JavaDoc nestedTasks = new Vector JavaDoc();
43
44     /**
45      * Add a nested task to Sequential.
46      * <p>
47      * @param nestedTask Nested task to execute Sequential
48      * <p>
49      */

50     public void addTask(Task nestedTask) {
51         nestedTasks.addElement(nestedTask);
52     }
53
54     /**
55      * Execute all nestedTasks.
56      *
57      * @throws BuildException if one of the nested tasks fails.
58      */

59     public void execute() throws BuildException {
60         for (Iterator JavaDoc i = nestedTasks.iterator(); i.hasNext();) {
61             Task nestedTask = (Task) i.next();
62             nestedTask.perform();
63         }
64     }
65 }
66
Popular Tags