KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > idaremedia > antx > starters > StrictInnerTaskSet


1 /**
2  * $Id: StrictInnerTaskSet.java 180 2007-03-15 12:56:38Z ssmc $
3  * Copyright 2002-2003 iDare Media, Inc. All rights reserved.
4  *
5  * Originally written by iDare Media, Inc. for release into the public domain. This
6  * library, source form and binary form, is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2 of the License, or (at your option) any later
9  * version.<p>
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
12  * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13  * See the GNU LGPL (GNU Lesser General Public License) for more details.<p>
14  *
15  * You should have received a copy of the GNU Lesser General Public License along with this
16  * library; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite
17  * 330, Boston, MA 02111-1307 USA. The LGPL can be found online at
18  * http://www.fsf.org/copyleft/lesser.html<p>
19  *
20  * This product has been influenced by several projects within the open-source community.
21  * The JWare developers wish to acknowledge the open-source community's support. For more
22  * information regarding the open-source products used within JWare, please visit the
23  * JWare website.
24  *----------------------------------------------------------------------------------------*
25  * WEBSITE- http://www.jware.info EMAIL- inquiries@jware.info
26  *----------------------------------------------------------------------------------------*
27  **/

28
29 package com.idaremedia.antx.starters;
30
31 import org.apache.tools.ant.BuildException;
32 import org.apache.tools.ant.Project;
33
34 /**
35  * Superclass of all "special" helper tasks within a strict outer taskset. Special
36  * helper tasks are usually tasksets executed in response to a particular kind-of event
37  * like a caught build exception or a matching case check. Note a strict inner class
38  * is by definition quiet except an alternative "go" API isn't necessary since the inner
39  * task can only be nested in a prescribed outer task that controls it.
40  *
41  * @since JWare/AntX 0.1
42  * @author ssmc, &copy;2002-2003 <a HREF="http://www.jware.info">iDare&nbsp;Media,&nbsp;Inc.</a>
43  * @version 0.5
44  * @.safety n/a
45  * @see StrictOuterTask
46  **/

47
48 public abstract class StrictInnerTaskSet extends TaskSet implements StrictInnerTask
49 {
50     /**
51      * Creates a new strict inner task. Must be associated with an
52      * enclosing task before functional.
53      **/

54     protected StrictInnerTaskSet(String JavaDoc iam)
55     {
56         super(iam);
57     }
58
59     /**
60      * Creates a new strict inner task with custom configuration delay.
61      * Must be associated with an enclosing task before functional.
62      **/

63     protected StrictInnerTaskSet(String JavaDoc iam, boolean delayConfiguration)
64     {
65         super(iam,delayConfiguration);
66     }
67
68
69     /**
70      * Returns this helper's enclosing block task.
71      **/

72     public final StrictOuterTask getEnclosingTask()
73     {
74         return m_enclosingTask;
75     }
76
77
78     /**
79      * Initializes this helper's enclosing block task. For now can
80      * only be done by a default AntX block task definitions.
81      **/

82     public final void setEnclosingTask(StrictOuterTask owner)
83     {
84         m_enclosingTask = owner;
85     }
86
87
88     /**
89      * Ensures this helper is enclosed within a block task before
90      * it can execute.
91      * @throws BuildException if not in valid target/project or not nested
92      * in the expected enclosing taskset.
93      **/

94     protected void verifyCanExecute_(String JavaDoc calr)
95         throws BuildException
96     {
97         super.verifyCanExecute_(calr);
98
99         if (getEnclosingTask()==null) {
100             String JavaDoc ermsg = uistrs().get("task.only.in.outer",getTaskName());
101             log(ermsg, Project.MSG_ERR);
102             throw new BuildException(ermsg,getLocation());
103         }
104     }
105
106
107     private StrictOuterTask m_enclosingTask;
108 }
109
110 /* end-of-StrictInnerTaskSet.java */
111
Popular Tags