David M. Smith wrote:
> Hi,
>
> I wanted to write a task along the following lines
>
> <mytask srcfile="" destfile="">
> <param find="Key1" replaceWith="Value1"/>
> <param find="Key2" replaceWith="Value2"/>
>
> <param find="Keyn" replaceWith="Valuen"/>
> </mytask>
> However, I would still like to understand how I would write this task.
Welcome to the world of Ant task writers! :)
> Looking at the Ant source code, it seems generic enough to be able to
> handle arbitary nested elements, but what methods must I put on my task
> class to support this? I am thinking createParam(), setParam() and
> getParam().
>
> Do I need to create a ant.types.Param class?
You could implement any class that you wanted that had a setFind(...)
and a setReplaceWith(...) methods (the types of these is quite flexible,
but lets just say String arguments for now.
Then your main task class would either implement createParam, addParam,
or addConfiguredParam. The simplest case is for your class that we
defined above to have a no-arg constructor and use the addParam() method.
Sounds a bit complex, but its not too difficult once you know some of
the basic rules/patterns that Ant's introspection mechanism uses.
Erik
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>