velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Emmanuel Boudrant <emmanuel.boudr...@gmail.com>
Subject Re: call replace('.', '_') on a VTL variabel
Date Mon, 13 Sep 2004 07:43:30 GMT
If I understand, it is impossible to call methods with primitives
types as parameters in velocity ?

-emmanuel

On Sun, 12 Sep 2004 19:14:11 +0200, Emmanuel Boudrant
<emmanuel.boudrant@gmail.com> wrote:
> Ok Thx ... I don't want to modify velocity context (add a tool), I
> will use replaceAll method.
> 
> -emmanuel
> 
> 
> 
> On Sun, 12 Sep 2004 13:06:58 -0400, Terry Steichen <terry@net-frame.com> wrote:
> > Correct, it won't work.  However, you can easily add a replace(String mainString,
String toReplaceString, String replacementString) method to a tool.  Then, on a string varb
$name, do something like $tool.replace($name,".", "_"),
> >
> >
> >
> >   ----- Original Message -----
> >   From: Emmanuel Boudrant
> >   To: Velocity Users List ; Shinobu Kawai
> >   Sent: Sunday, September 12, 2004 12:52 PM
> >   Subject: Re: call replace('.', '_') on a VTL variabel
> >
> >   You mean with #set ($codedName = $name.replace('.', '_')) '.' and '_'
> >   are String, not char. So it doesn't work ?
> >
> >   On Mon, 13 Sep 2004 00:58:41 +0900, Shinobu Kawai
> >   <shinobu.kawai@gmail.com> wrote:
> >   > Hi emmanuel,
> >   >
> >   >
> >   >
> >   > > Is it possible to call a java.lang.String method on a variable like
this :
> >   > >
> >   > > #set ($codedName = $name.replace('.', '_'))
> >   > >
> >   > > What is exactly the type of variable $name (java.lang.String?)
> >   > Whatever type of object you put in it.  If it's a primitive type, it
> >   > would be the wrapper object for it.  i.e. int becomes Integer.
> >   >
> >   > So the answer to your first question would be, yes, if you put a String
> >   > in $name, and String has a public method #replace(String, String).  I
> >   > don't know about the first half, but the second half is false.  You will
> >   > have to use #replaceAll(String, String), or create Character variables
> >   > to give to #replace(char, char).
> >   >
> >   > Best regards,
> >   > -- Shinobu Kawai
> >   >
> >   > --
> >   > Shinobu Kawai(shinobu.kawai@gmail.com)
> >   >
> >   > ---------------------------------------------------------------------
> >   > 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
> >
> >
>

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


Mime
View raw message