ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From MCG QA <mc...@yahoo.com>
Subject Re: AW: Extracting key,value from a property
Date Mon, 05 Jul 2004 22:54:10 GMT
Thank Jan,

I wanted to acccess "AuthorAddressEntityBean" as
${key}. Had little hard time with <propertyregexp>,
esp. the parameter regexp, but ultimately I could
split the ${key} and ${value}. Thanks for your inputs.
Here is what I did.

<target name="for-each-test"> 
<loadfile property="ejb-value-loc"
srcFile="c:/temp/envs.txt"/>
<foreach list="${ejb-value-loc}" delimiter="&#x0A;"
param="cur-ejb-value-loc" target="loop-target">
</foreach>
</target> 
	
<target name="loop-target">
 <propertyregex property="ejb.name"
    input="${cur-ejb-value-loc}"
    regexp="([^@]*)"
    select="\0"
    casesensitive="false" />
 
 <propertyregex property="ejb.value"
    input="${cur-ejb-value-loc}"
    regexp="([^@.]*$)"
    select="\0"
    casesensitive="false" />
<echo>Complete String : ${cur-ejb-value-loc}</echo>
<echo>ejb-name : ${ejb.name}</echo>		
<echo>ejb-location : ${ejb.value}</echo>              
</target>


I modified the property file env.txt which contains
values as under:

AuthorAddressEntityBean@c:/temp


================================================
--- Jan.Materne@rzf.fin-nrw.de wrote:
> If you only want to have the properties loaded
> simply use <property
> file=""/>.
> 
> If you want to access the "AuthorAddressEntityBean"
> as ${key} simply split
> the 
> value.
> - using AntContribs <propertyregexp>
> - using <script> and java.lang.String.split()
> 
> Jan
> 
> > -----Ursprüngliche Nachricht-----
> > Von: MCG QA [mailto:mcgqa@yahoo.com]
> > Gesendet am: Freitag, 2. Juli 2004 23:49
> > An: Ant Users List
> > Betreff: Extracting key,value from a property
> > 
> > I have a property file env.txt which contains
> values
> > as under:
> > 
> > AuthorAddressEntityBean=c:/temp
> > AuthorDetailsSessionBean=c:/bea
> > AuthorEntityBean=c:/b-copy
> > AuthorXrefEntityBean=c:/WEB-INF
> > BindingXref=c:/PVCS
> > BiographiesSessionBean=c:/mhhe-build
> > CommonSessionBean=c:/qalogs
> > CompetCategorySessionBean=c:/qalogs/mhhe
> > 
> > I'm using <foreach> task and set it as a property 
> as
> > under:
> > 
> > <foreach list="${environments}" delimiter="
"
> > param="CurEnv" target="loop-target"/>
> > 
> > 
> > And when I execute this task, which is basically
> an
> > echo at this moment, I would get the following
> values
> > for Curenv for each iteration/line:
> > Curenv:AuthorAddressEntityBean=c:/temp
> > Curenv:AuthorDetailsSessionBean=c:/bea
> > Curenv:AuthorEntityBean=c:/b-copy
> > etc...
> > 
> > What I would like to do is to extract each of the
> > above as both key and value, into two separate
> > variables.
> > 
> > for example, my <foreach> task would return me a
> > property "AuthorAddressEntityBean=c:/temp"
> > 
> > I would like to extract from this property the
> > following: 
> > "key" = AuthorAddressEntityBean
> > "value" = c:/temp 
> > in this case.
> > 
> > How can I do this?



		
__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - Send 10MB messages!
http://promotions.yahoo.com/new_mail 

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


Mime
View raw message