KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cactus > integration > ant > util > DefaultAntTaskFactory


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

20 package org.apache.cactus.integration.ant.util;
21
22 import org.apache.tools.ant.Location;
23 import org.apache.tools.ant.Project;
24 import org.apache.tools.ant.Target;
25 import org.apache.tools.ant.Task;
26
27 /**
28  * Default {@link AntTaskFactory} for creating Ant tasks.
29  *
30  * @version $Id: DefaultAntTaskFactory.java,v 1.1 2004/05/31 20:05:24 vmassol Exp $
31  */

32 public class DefaultAntTaskFactory implements AntTaskFactory
33 {
34     /**
35      * The current {@link Project} being executed.
36      */

37     private Project currentProject;
38     
39     /**
40      * The current Ant task being executed.
41      */

42     private String JavaDoc currentTaskName;
43     
44     /**
45      * The current {@link Location} of the Task being executed.
46      */

47     private Location currentLocation;
48     
49     /**
50      * The current {@link Target} being executed.
51      */

52     private Target currentOwningTarget;
53
54     /**
55      * @param theProject the current project
56      * @param theCurrentTaskName the current Ant task name
57      * @param theCurrentLocation the current task location
58      * @param theCurrentTarget the current target being executed
59      */

60     public DefaultAntTaskFactory(Project theProject,
61         String JavaDoc theCurrentTaskName, Location theCurrentLocation,
62         Target theCurrentTarget)
63     {
64         this.currentProject = theProject;
65         this.currentTaskName = theCurrentTaskName;
66         this.currentLocation = theCurrentLocation;
67         this.currentOwningTarget = theCurrentTarget;
68     }
69
70     /**
71      * @see AntTaskFactory#createTask(String)
72      */

73     public Task createTask(String JavaDoc theName)
74     {
75         Task retVal = this.currentProject.createTask(theName);
76         if (retVal != null)
77         {
78             retVal.setTaskName(this.currentTaskName);
79             retVal.setLocation(this.currentLocation);
80             retVal.setOwningTarget(this.currentOwningTarget);
81         }
82         return retVal;
83     }
84 }
85
Popular Tags