THANKS Erik,
everything seems to be working fine right now.
Am Samstag, 13. April 2002 03:43 schrieben Sie:
> Your Parameter class is subclassing from Task. Parameter itself is not a
> Task so simply remove it from the extends clause so that its just an
> Object.
>
> Also, I would highly recommend you use the addXXX methods to inject your
> Parameter subelements. Like this:
>
> public void addParameter (com.tcheer.xalANTask.Parameter parameter) {
> this.m_params.add (parameter);
> }
>
> Ant will take of constructing your Parameter instance for you automatically
> (as long as it can, of course).
>
> Actually, on second glance, you're probably interpretting that its not
> setting name/value appropriately prematurely. It is not until the
> execute() method when everything is completely populated. And no, you
> don't need getter methods, unless you need them yourself for some reason.
> Could you detail your findings more if this advice doesn't solve it all?
>
> Erik
>
>
> ----- Original Message -----
> From: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> To: "ant-user" <[EMAIL PROTECTED]>
> Sent: Friday, April 12, 2002 9:24 PM
> Subject: building my own task...
>
> > Hi,
> >
> > I have been reading an article in a java magazine about how to create
>
> one's
>
> > own ant task. Since then I am trying to excercise on it.
> >
> > I am defining a task, lets say "MyTask". MyTask has a sub element
>
> "Parameter"
>
> > with both "name" and "value" attribute, so I have written an
> > org.apache.ant.Task subclass named Parameter and in my "main" programm
> > containing the execute method I also have the method "public
> > com.myDomain.Parameter createParameter ()" and both "Parameter m_param"
>
> and
>
> > "Vector m_params" (since it should be possible to have more than one
> > parameter...). The following implementation:
> >
> > public com.tcheer.xalANTask.Parameter createParameter () {
> > //System.out.println ("+ createParameter");
> > this.m_param = new Parameter ();
> > this.m_params.add (this.m_param);
> > //System.out.println("\tout");
> > return m_param;
> > }
> >
> > seems not to create a Parameter object with both name and value, but
> > gives
>
> me
>
> > an empty object. Actually it is obvious
> >
> > Please I would appreciate any contribution from you if you think you can
>
> help.
>
> > PS: The Parameter.java
> > class Parameter extends org.apache.ant.Task {
> > Parameter () {...}
> > public void setName (String name) {...}
> > public void setValue (String value) {...}
> > //and the equivalent getMethods (though I think I don't need them, do I?)
> > private String m_pname;
> > private String m_pvalue;
> > }
> >
> > --
> > Eric Tchepannou
> >
> > --
> > To unsubscribe, e-mail:
> > <mailto:[EMAIL PROTECTED]> For additional commands,
> > e-mail: <mailto:[EMAIL PROTECTED]>
--
Eric Tchepannou
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>