You should really try to avoid being too clever in a template. Java is good for doing logical operations. Templates are good for creating content. Try to keep the business logic in Java.

Btw, to split on '.' in Java you'd need to do "\\.". You need to escape the backslash so that a literal backslash goes to the regexp evaluator. But in a template you'd just need something like $mask.split('\.'). Note the use of single quotes!

If you want to use a static method you need to wrap it with an instance method. As long as you're doing that why not just implement the full method to do what you need. Make life easier for yourself. Write yourself a method which does the right thing. And toss an instance of that object into your Context.

Jason Pettiss
[EMAIL PROTECTED]

Ramin Dousti wrote:

Hello,

I have a simple macro which is supposed to receive a netMask (say
255.255.0.0) and convert it to an inverseMask 0.0.255.255.

The first problem is: how can I split on "."? I tried ".", "\.", "\\."
and so forth but none worked.

The second question is: given a string "128", how can I subtract it
from 255? I tried:

#set( $byte = "128" )
#set( $result = 255 - Integer.parseInt($byte) )

But, velocity doesn't like Integer.parseInt() static method.

Thanks in advance,



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to