> -----Original Message-----
> From: stephan beal [mailto:[EMAIL PROTECTED]

>
> On a related, but separate, note:
> The "developing with ant" section in the docs says:
> -------------
> For each nested element, write a create or add method. A create
> method must
> be a public method that takes no arguments and returns an Object
> type. The
> name of the create method must begin with create, followed by the element
> name. An add method must be a public void method that takes a
> single argument
> of an Object type with a no-argument constructor. The name of the
> add method
> must begin with add, followed by the element name.
> -------------
>
> Can someone tell me what the technical difference is between addXXX() and
> createXXX()? i was thinking that you "add" command-line args to
> an ExecTask,
> but it has no addXXX() (it has only createXXX()).
>

The difference is mainly in where the object gets instantiated.  For an
addX() method, Ant instantiates it.  For a createX() method, the task/type
instantiates it.

Here's how a <foo> element is handled using an addFoo( Type arg ) method:

- Create a new instance of Type, using the no-args constructor.
- Call addFoo() to hand the object to the task/type.
- Configure the object using the <foo> element.

Here's how the element is handled using a Type createFoo() method:

- Create an instance of Type, by calling createFoo().  The task/type creates
the instance however it wants.
- Configure the object using the <foo> element.

There's actually a third type of method, the addConfiguredX() method, that
is a variation of addX().  A <foo> element is handled using
addConfiguredFoo( Type arg ) method:

- Create a new instance of Type, using the no-args constructor.
- Configure the object using the <foo> element.
- Call addConfiguredFoo() to hand the object to the task/type.

I suggest using addX() or addConfiguredX() where possible.


Adam


--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to