You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by Arnaud HERITIER <ah...@gmail.com> on 2007/02/02 00:39:16 UTC

Re: How to check value of a variable is numeric?

Not really a quick reply but something like that can do it (not tested) :

    <j:set
      var="_exception"
      value="${null}" />
    <j:catch var="_exception">
      <echo>***** Try to clean project</echo>
      <j:set var="_integer_prop"  value="${my.integer.property}"/>
      <j:set var="_integer_obj"  value="${Integer.parseInt
(_integer_prop)}"/>
    </j:catch>
    <j:if test="${_exception1 != null}">
      <fail>my.integer.property (${my.integer.property}) isn't an
Integer</fail>
    </j:if>
    <echo>my.integer.property (${my.integer.property}) is an Integer</echo>

  To reuse it you can hide it in a custom taglib for jelly

Arnaud


On 1/31/07, Nalaka Gamage <NG...@virtusa.com> wrote:
>
> Hi All,
>
> I am using Maven 1.o.
>
> I there a way to check if the value of a variable is numeric in Maven?
>
>
>
> If not is it possible to use Ant call (if any) ?
>
>
>
> Quick response is highly appreciated.
>
>
>
> Regards,
>
> Nalaka
>
>
>
>
>

Re: How to check value of a variable is numeric?

Posted by Arnaud HERITIER <ah...@gmail.com>.
       <echo>***** Try to clean project</echo> is a bad cut'n paste ;-)

On 2/2/07, Arnaud HERITIER <ah...@gmail.com> wrote:
>
> Not really a quick reply but something like that can do it (not tested) :
>
>     <j:set
>       var="_exception"
>       value="${null}" />
>     <j:catch var="_exception">
>       <echo>***** Try to clean project</echo>
>       <j:set var="_integer_prop"  value="${my.integer.property}"/>
>       <j:set var="_integer_obj"  value="${Integer.parseInt(_integer_prop)}"/>
>     </j:catch>
>     <j:if test="${_exception1 != null}">
>       <fail>my.integer.property (${my.integer.property}) isn't an
> Integer</fail>
>     </j:if>
>     <echo>my.integer.property (${my.integer.property}) is an
> Integer</echo>
>
>   To reuse it you can hide it in a custom taglib for jelly
>
> Arnaud
>
>
> On 1/31/07, Nalaka Gamage <NGamage@virtusa.com > wrote:
> >
> > Hi All,
> >
> > I am using Maven 1.o.
> >
> > I there a way to check if the value of a variable is numeric in Maven?
> >
> >
> >
> > If not is it possible to use Ant call (if any) ?
> >
> >
> >
> > Quick response is highly appreciated.
> >
> >
> >
> > Regards,
> >
> > Nalaka
> >
> >
> >
> >
> >
>