ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Adam Leggett (UPCO)" <adam.legg...@upco.co.uk>
Subject Re: Parsing comma-separated string and getting handle to each token
Date Mon, 23 Nov 2009 10:22:28 GMT
To solve your problem, i'd suggest a scripted approach using something
like the <groovy> or <scriptdef> task. If using groovy for example, this
would allow you to use similar Java code as in your suggestion and give
you much more fine grained control over error handling etc e.g. if the
data in the file is malformed for some reason or the file is missing.

Thanks

Adam


On Mon, 2009-11-23 at 02:06 -0800, rohit15 wrote:
> Hi gurus,
> 
> Can you please help me resolve this seemingly simple requirement.
> 
> I have a my.txt file like
> localVariable1,propVariable11,propVariable12
> localVariable2,propVariable21,propVariable22
> localVariable3,propVariable31,propVariable32
> 
> 
> I need to parse this line by line and then process each line. While
> processing each line, I need to execute separate logic on the 2nd and 3rd
> variables of each line.
> 
> I've been able to parse each line using the following code. However, I
> haven't succeeded in getting handle to 2nd and 3rd variables by reference 
> [For e.g. in Java, I'd have iterated using stringtokenizer and referred as
> stringtkr.token[1], or token[2]  -something on those lines]
> 
> 
> <macrodef name="printline">
> <attribute name="lineparam"/>
> <sequential>
> <echo>Line param :: @{lineparam}</echo>
> 
> <for list="@{lineparam}" param="testparam" delimiter=','>
> <sequential>
> <property name="@{testparam}" value="This is dummy value for @{testparam}"/>
> <!-- How do I refer specifically to 1st token and then 2nd and then 3rd? -->
> </sequential>
> </for>
> </sequential>
> </macrodef>
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message