ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Saunders <>
Subject Taskdefs
Date Wed, 16 Aug 2000 14:18:02 GMT
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
To all:
<p>How can a taskdef detect when one an attribute has been set? Given that
a taskdef has the following set method:
<pre>public class myTask extends Task {
&nbsp;&nbsp;&nbsp; private boolean myCond = false;

&nbsp;&nbsp;&nbsp; //..

&nbsp;&nbsp;&nbsp; public void setMycond(boolean myCond)
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; this.myCond = myCond;
&nbsp;&nbsp;&nbsp; }

&nbsp;&nbsp;&nbsp; //..

&nbsp;&nbsp;&nbsp; public void execute() throws BuildException {
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; // was myCond set?
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if (myCond == true)
// yes, do some operation
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; } else {
// maybe yes, maybe no..
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }
&nbsp;&nbsp;&nbsp; }
how can one determine in the <tt>execute</tt> method if <tt>myCond</tt>
was set other than comparing the value against the default value set in
the implicit constructor? In other words is there a facility in the subclasses
to see if a given attribute was set in the <tt>build.xml</tt> file or do
I have to keep around another boolean, <tt>haveMyCond</tt>, that I set
in the <tt>setMycond</tt> method and test against in the <tt>execute</tt>

View raw message