You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Martin Nattrodt <ma...@x-root.de> on 2003/02/14 08:56:55 UTC

How to compare numbers with strings

Hello,

I have a problem.

I want do something like:

    #if ( ( $col.Type == "VARCHAR") && ( $col.getSize() > 255 ))
        #set ( $type2 = "BLOB" )
        #set ( $size = "" )
    #end

The expression:
($col.getSize() > 255 )
does not work.


($col.getSize() == "4000" )
works with $col.getSize() is 4000

but 
($col.getSize() == 4000 )
does not work.


How can I compare a int with a String?

regards
Martin

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


RE: How to compare numbers with strings

Posted by pero <me...@gmx.de>.
  Could it be that $col.getSize() returns a long and not an int?
Velocity cannot deal with longs :(
So the hack Denis proposed would be the last option.

Peter

> -----Original Message-----
> From: Martin Nattrodt [mailto:martin.nattrodt@x-root.de] 
> Sent: Friday, February 14, 2003 8:57 AM
> To: 'velocity-user@jakarta.apache.org'
> Subject: How to compare numbers with strings
> 
> 
> Hello,
> 
> I have a problem.
> 
> I want do something like:
> 
>     #if ( ( $col.Type == "VARCHAR") && ( $col.getSize() > 255 ))
>         #set ( $type2 = "BLOB" )
>         #set ( $size = "" )
>     #end
> 
> The expression:
> ($col.getSize() > 255 )
> does not work.
> 
> 
> ($col.getSize() == "4000" )
> works with $col.getSize() is 4000
> 
> but 
> ($col.getSize() == 4000 )
> does not work.
> 
> 
> How can I compare a int with a String?
> 
> regards
> Martin
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 


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


Re: Velocity + Turbine

Posted by Daniel Dekany <dd...@freemail.hu>.
Friday, February 14, 2003, 1:53:35 PM, Bobirkhon Ismailov wrote:

> Hello, I have read about Velocity and its commitment to Turbine. I would
> really appreciate if you point me to a manual describing the use of
> Velocity with Turbine.  
>
> Also, I am new to Velocity and templating languages in general, so I'd
> like to know your comparison of Velocity to other TPLs, in particular to
> FreeMarker.

Well, there is a somewhat updated comparison available since yesterday
night on http://freemarker.org/fmVsVel.html ... just it is from the
authors of FM... :)

-- 
Best regards,
 Daniel Dekany



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


Velocity + Turbine

Posted by Bobirkhon Ismailov <bi...@uzavtoyul.uz>.
Hello, I have read about Velocity and its commitment to Turbine. I would
really appreciate if you point me to a manual describing the use of
Velocity with Turbine.  

Also, I am new to Velocity and templating languages in general, so I'd
like to know your comparison of Velocity to other TPLs, in particular to
FreeMarker.

Thank you.

Bobirkhon Ismailov



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


Re: How to compare numbers with strings

Posted by Denis <br...@mac.com>.
Hi Martin
On Friday, February 14, 2003, at 07:56  am, Martin Nattrodt wrote:

> Hello,
>
> I have a problem.
>
> I want do something like:
>
>     #if ( ( $col.Type == "VARCHAR") && ( $col.getSize() > 255 ))
>         #set ( $type2 = "BLOB" )
>         #set ( $size = "" )
>     #end
>
> The expression:
> ($col.getSize() > 255 )
> does not work.
>
>
> ($col.getSize() == "4000" )
> works with $col.getSize() is 4000

Could you have the col size put in the context as an integer instead of 
a string?
Alternatively, you could use this little hack:

#set ( $number = 1 ) ## Gives access to java.lang.Integer methods
#if ( ( $col.Type == "VARCHAR") && ( $number.valueOf($col.getSize()) > 
255 ))

Cheers,
-- Denis.

>
> but
> ($col.getSize() == 4000 )
> does not work.
>
>
> How can I compare a int with a String?
>
> regards
> Martin


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