ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Murdoch" <adammurdoch...@yahoo.com>
Subject RE: Ant Task Development Question - Nested Elements with Nested Elements
Date Fri, 18 Jan 2002 00:37:23 GMT

Hi,

You have plenty of options for the nested elements.  Certainly, your first
approach is fine.  The second one, well, you shouldn't really be extending
Task for your <bar> class.

Here's what you can do:

Your <foo> class has to be public, extend Task, and have a public no-args
constructor.  No choice there.

As far as the nested elements go, they can be either top-level or inner
classes, doesn't matter.  The nesting in the build file is determined by the
addX() and createX() methods that a class has, not what the inner classes
are.  Provided your <bar> class has one of the following methods, then you
can nest <baz> elements inside <bar> elements:

public void addBaz(BazClass baz);
public void addConfiguredBaz(BazClass baz); <-- best option
public BazClass createBaz();

Where BazClass could be top-level, or could be BarClass.BazClass, or could
be FooClass.BarClass.BazClass.  I'd suggest you make them all top-level
classes, so you can reuse them elsewhere, and nest them in different ways.

Also, the <bar> and <baz> classes only really need to extend DataType if you
want to use them by reference.  If you don't care about using them by
reference, you can just make 'em regular Objects.


Adam

> -----Original Message-----
> From: George Lee [mailto:GeorgeLee@truexchange.com]
> Sent: Friday, 18 January 2002 9:57 AM
> To: Ant Developers List
> Subject: Ant Task Development Question - Nested Elements with Nested
> Elements
>
>
> I am currently developing an ant task that requires the following xml
> structure:
>
> <foo value1="blah" value2="blah" ... >
> 	<bar value3="blah" value4="blah" ... >
> 		<baz value5="blah" value5="blah" ... />
> 		<baz value5="blah" value5="blah" ... />
> 	</bar>
> 	<bar value3="blah" value4="blah" ... >
> 		<baz value5="blah" value5="blah" ... />
> 	</bar>
> </foo>
>
> I've attempted implementing
>
> 1)	"foo" as a Task,
> 	"bar" being an inner class of type DataType of "foo",
> 	and "baz" being an inner class of type DataType of "bar".
>
> and
>
> 2) 	"foo" as a Task that implements TaskContainer,
> 	"bar" being a Task with no execute() method,
> 	and "baz" being an inner class of type DataType of "bar".
>
> Is it possible to have recursively nested elements for a task and/or
> are either of the ways I've tried implementing this on the right track?
>
> Thanks
>
> George Lee
> Software Engineer
> TruExchange, Inc
> http://www.truexchange.com
>
> --
> To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
> For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message