Java Mailing List Archive

http://www.ant-tasks.com/

Home » Ant Users List »

AW: Decrare a property array

Jan Materne

2008-05-19

Replies:

Author LoginPost Reply
> property task would allow decraration of single name and value.
However I
> would like to have a property which is like java hash map or
String[][]
> double array. Is there a direct way to have such properties..(not
looking to
> use groovey or some other script)

As Ant is not a programming language there is no support for that.
As described in
http://ant.apache.org/manual/tutorial-tasks-filesets-properties.html#ret
urning-list you can create your own list-syntax and parse that. E.g:
  a=1;b=2;c=3
  --> split on ';' for separating the key-value-pairs
  --> then split on '=' for separating the keys from their values


> Also, what is the way to have macro's defined so that it accepts such
array
> attributes. I am ware of macros which only take attribute which is not
an array.

With the your own syntax you just have a normal property which you can
pass in.
But I would suggest using <scriptdef> instead of <macrodef> as you can
use language split- and loop-functions.

But better would be implementing the task in Java as you can support you
need natively
  <my:replace file="">
    <param search="foo" replace="bar"/>
    <param search="hello" replace="world"/>
  </my:replace>

  public class ReplaceTask extends Task {
    public void setFile(java.io.File file) { ... }
    public void add(Param p) { paramList.add(p); }
    class Param {
       public setSearch(String s) { ... }
       public setReplace(String r) { ... }
    }
  }


Jan


>
> I am writing this in the context of writing a macro, which
> does replacing of
> certain set of key value pairs in a given file.
>
> Regards,
> Nagendra
> --
> View this message in context:
> http://www.nabble.com/Decrare-a-property-array-tp17281261p1728
1261.html
> Sent from the Ant - Users mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@(protected)
> For additional commands, e-mail: user-help@(protected)
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@(protected)
For additional commands, e-mail: user-help@(protected)

©2008 ant-tasks.com - Jax Systems, LLC, U.S.A.