You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Guy Catz <Gu...@waves.com> on 2008/08/17 14:32:54 UTC

make a string lowercase

Is it possible to make a string lowercase (or uppercase)?
Something like ....
<lowercase var="myVar" property="newVar" />

${myVar} can be "Release", while after calling <lowercase>, ${newVar} will be set to "release".

Does something like this exist?

Thanks.


Re: make a string lowercase

Posted by webplusplus <to...@googlemail.com>.
Just use embedded scripting support. So no addons are required.

<target name="build">
  

  ...
</target>


--
View this message in context: http://ant.1045680.n5.nabble.com/make-a-string-lowercase-tp1352626p5074090.html
Sent from the Ant - Users mailing list archive at Nabble.com.

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


Re: make a string lowercase

Posted by wolfgang haefelinger <wh...@gmail.com>.
> The simplest is to use Antelope tasks:  http://antelope.tigris.org/nonav/docs/manual/bk03ch13.html

Rather simple is also

<property name="newVar" value="${  myVar.tolower }" />

which you would get by enabling Flaka's  [1] property helper.

Also checkout [2] for many other 'String' properties and functions
working on (String) objects. For example, you could also utilize
Java's Formatter [3] capabilities for additional conversion mechanics,
like shown here for creating the 'uppercase' property:

<property name="newVar" value="${ format('%S', myVar)  }" />

An upcoming version of Flaka will allow you to define your very own functions.


[1] http://code.google.com/p/flaka
[2] http://flaka.googlecode.com/files/flaka.pdf
[3] http://download.oracle.com/javase/1.5.0/docs/api/java/util/Formatter.html


On Mon, Jan 10, 2011 at 9:19 PM, Shawn Castrianni
<Sh...@halliburton.com> wrote:
> The simplest is to use Antelope tasks:  http://antelope.tigris.org/nonav/docs/manual/bk03ch13.html
>
> That URL shows using the lowercase task in the very first example.
>
> ---
> Shawn Castrianni
>
>
> -----Original Message-----
> From: Gilbert Rebhan [mailto:gilreb@maksimo.de]
> Sent: Monday, January 10, 2011 2:11 PM
> To: Ant Users List
> Subject: Re: make a string lowercase
>
> -------- Original Message  --------
> Subject: Re: make a string lowercase
> From: halfsetgelly <sj...@legacysd.com>
> To: user@ant.apache.org
> Date: 07.01.2011 14:19
>
>> You could use  http://ant.apache.org/manual/Tasks/pathconvert.html
>> <pathconvert>  and a
>> http://ant.apache.org/manual/Types/mapper.html#script-mapper scriptmapper
>>
>>
>>  <property name="mixed" value="Foo_Baa"/>
>>
>>   <pathconvert property="converted">
>>    <path path="${mixed}"/>
>>    <chainedmapper>
>>     <flattenmapper/>
>>     <scriptmapper language="javascript">
>>      self.addMappedName(source.toLowerCase());
>>     </scriptmapper>
>>     </chainedmapper>
>>   </pathconvert>
>>
>>   <echo>${converted}</echo>
>
> or use flaka [1], example script with some possibilities =
>
> <project xmlns:fl="antlib:it.haefelinger.flaka">
>
>  <property name="mixed" value="Foo_Baa" />
>  <echo>$${mixed} = ${mixed}</echo>
>  <!-- with <fl:install-property-handler/>
>  <echo>${mixed} tolower => #{mixed.tolower}</echo>
>  -->
>  <!-- echo tolower -->
>  <fl:echo>${mixed} tolower => #{mixed.tolower}</fl:echo>
>  <!-- overwrite existing property -->
>  <fl:let>mixed ::= mixed.tolower</fl:let>
>  <echo>$${mixed} overwritten = ${mixed}</echo>
>  <!-- create new property -->
>  <fl:let>mixed_tolower := mixed.tolower</fl:let>
>  <echo>$${mixed_tolower} = ${mixed_tolower}</echo>
>
> </project>
>
> output =
>
> [echo] ${mixed} = Foo_Baa
> [fl:echo] Foo_Baa tolower => foo_baa
> [echo] ${mixed} overwritten = foo_baa
> [echo] ${mixed_tolower} = foo_baa
>
> [1] http://code.google.com/p/flaka/
> when downloading the jar with inlined dependencies,
> no further libraries are needed =
> [2] http://code.google.com/p/flaka/downloads/list
>    (ant-flaka-1.02.00.jar)
>
>
> Regards, Gilbert
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
> ----------------------------------------------------------------------
> This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>



-- 
Wolfgang Häfelinger
häfelinger IT - Applied Software Architecture
http://www.haefelinger.it
+31 648 27 61 59

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


RE: make a string lowercase

Posted by Shawn Castrianni <Sh...@halliburton.com>.
The simplest is to use Antelope tasks:  http://antelope.tigris.org/nonav/docs/manual/bk03ch13.html

That URL shows using the lowercase task in the very first example.

---
Shawn Castrianni


-----Original Message-----
From: Gilbert Rebhan [mailto:gilreb@maksimo.de] 
Sent: Monday, January 10, 2011 2:11 PM
To: Ant Users List
Subject: Re: make a string lowercase

-------- Original Message  --------
Subject: Re: make a string lowercase
From: halfsetgelly <sj...@legacysd.com>
To: user@ant.apache.org
Date: 07.01.2011 14:19

> You could use  http://ant.apache.org/manual/Tasks/pathconvert.html
> <pathconvert>  and a 
> http://ant.apache.org/manual/Types/mapper.html#script-mapper scriptmapper 
> 
> 
>  <property name="mixed" value="Foo_Baa"/>
> 
>   <pathconvert property="converted">
>    <path path="${mixed}"/>
>    <chainedmapper>
>     <flattenmapper/>
>     <scriptmapper language="javascript">
>      self.addMappedName(source.toLowerCase());
>     </scriptmapper>
>     </chainedmapper>
>   </pathconvert>
> 
>   <echo>${converted}</echo>

or use flaka [1], example script with some possibilities =

<project xmlns:fl="antlib:it.haefelinger.flaka">

 <property name="mixed" value="Foo_Baa" />
 <echo>$${mixed} = ${mixed}</echo>
 <!-- with <fl:install-property-handler/>
 <echo>${mixed} tolower => #{mixed.tolower}</echo>
 -->
 <!-- echo tolower -->
 <fl:echo>${mixed} tolower => #{mixed.tolower}</fl:echo>
 <!-- overwrite existing property -->
 <fl:let>mixed ::= mixed.tolower</fl:let>
 <echo>$${mixed} overwritten = ${mixed}</echo>
 <!-- create new property -->
 <fl:let>mixed_tolower := mixed.tolower</fl:let>
 <echo>$${mixed_tolower} = ${mixed_tolower}</echo>

</project>

output =

[echo] ${mixed} = Foo_Baa
[fl:echo] Foo_Baa tolower => foo_baa
[echo] ${mixed} overwritten = foo_baa
[echo] ${mixed_tolower} = foo_baa

[1] http://code.google.com/p/flaka/
when downloading the jar with inlined dependencies,
no further libraries are needed =
[2] http://code.google.com/p/flaka/downloads/list
    (ant-flaka-1.02.00.jar)


Regards, Gilbert



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

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

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


Re: make a string lowercase

Posted by Gilbert Rebhan <gi...@maksimo.de>.
-------- Original Message  --------
Subject: Re: make a string lowercase
From: halfsetgelly <sj...@legacysd.com>
To: user@ant.apache.org
Date: 07.01.2011 14:19

> You could use  http://ant.apache.org/manual/Tasks/pathconvert.html
> <pathconvert>  and a 
> http://ant.apache.org/manual/Types/mapper.html#script-mapper scriptmapper 
> 
> 
>  <property name="mixed" value="Foo_Baa"/>
> 
>   <pathconvert property="converted">
>    <path path="${mixed}"/>
>    <chainedmapper>
>     <flattenmapper/>
>     <scriptmapper language="javascript">
>      self.addMappedName(source.toLowerCase());
>     </scriptmapper>
>     </chainedmapper>
>   </pathconvert>
> 
>   <echo>${converted}</echo>

or use flaka [1], example script with some possibilities =

<project xmlns:fl="antlib:it.haefelinger.flaka">

 <property name="mixed" value="Foo_Baa" />
 <echo>$${mixed} = ${mixed}</echo>
 <!-- with <fl:install-property-handler/>
 <echo>${mixed} tolower => #{mixed.tolower}</echo>
 -->
 <!-- echo tolower -->
 <fl:echo>${mixed} tolower => #{mixed.tolower}</fl:echo>
 <!-- overwrite existing property -->
 <fl:let>mixed ::= mixed.tolower</fl:let>
 <echo>$${mixed} overwritten = ${mixed}</echo>
 <!-- create new property -->
 <fl:let>mixed_tolower := mixed.tolower</fl:let>
 <echo>$${mixed_tolower} = ${mixed_tolower}</echo>

</project>

output =

[echo] ${mixed} = Foo_Baa
[fl:echo] Foo_Baa tolower => foo_baa
[echo] ${mixed} overwritten = foo_baa
[echo] ${mixed_tolower} = foo_baa

[1] http://code.google.com/p/flaka/
when downloading the jar with inlined dependencies,
no further libraries are needed =
[2] http://code.google.com/p/flaka/downloads/list
    (ant-flaka-1.02.00.jar)


Regards, Gilbert



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


Re: make a string lowercase

Posted by halfsetgelly <sj...@legacysd.com>.
You could use  http://ant.apache.org/manual/Tasks/pathconvert.html
<pathconvert>  and a 
http://ant.apache.org/manual/Types/mapper.html#script-mapper scriptmapper 


 <property name="mixed" value="Foo_Baa"/>

  <pathconvert property="converted">
   <path path="${mixed}"/>
   <chainedmapper>
    <flattenmapper/>
    <scriptmapper language="javascript">
     self.addMappedName(source.toLowerCase());
    </scriptmapper>
    </chainedmapper>
  </pathconvert>

  <echo>${converted}</echo>
-- 
View this message in context: http://ant.1045680.n5.nabble.com/make-a-string-lowercase-tp1352626p3331823.html
Sent from the Ant - Users mailing list archive at Nabble.com.

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


Re: make a string lowercase

Posted by Dale Anson <da...@grafidog.com>.
Antelope has this, see docs here:

http://antelope.tigris.org/nonav/docs/manual/bk03ch13.html

Dale


Guy Catz wrote:
> Is it possible to make a string lowercase (or uppercase)?
> Something like ....
> <lowercase var="myVar" property="newVar" />
>
> ${myVar} can be "Release", while after calling <lowercase>, ${newVar} will be set to "release".
>
> Does something like this exist?
>
> Thanks.
>
>
>   

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