You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by sc...@btopenworld.com on 2003/01/16 18:08:42 UTC

Re: Where has commons lang Strings.interpolate(String text, Map map) gone?

This method was removed for 1.0 due to its specific nature.

Sorry.

Stephen

>  from:    Simon Moore <Si...@condisline.com>
>  date:    Thu, 16 Jan 2003 11:10:59
>  to:      commons-dev@jakarta.apache.org
>  subject: Re: Where has commons lang Strings.interpolate(String text, Map map)  gone?
> 
> > I've been cleaning up some alod code dependant on commons-lang 0.1-dev to
> > depend on commons-lang 1.0 but I'm missing the 
> > Strings.interpolate(String text, Map map) in StringUtils???
> > 
> > Does anyone know where it went?
> > 
> > Regards,
> > 
> >  Saimon
> > 
> > 
> 
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
> 


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Where has commons lang Strings.interpolate(String text, Map map) gone?

Posted by Henri Yandell <ba...@generationjava.com>.
Yeah, they wouldn't let me keep it :(

The method is in com.generationjava.util.Interpolator
[http://www.generationjava.com/projects/GenJavaCore.shtml], or, as you
probably won't want more dependencies, [and as GJ uses Namespace not Map]
it ought to just be:

    static public String interpolate(String text, Map namespace) {
        Iterator keys = namespace.keySet().iterator();
        while(keys.hasNext()) {
            String key = keys.next().toString();
            Object obj = namespace.get(key);
            String value = obj.toString();
            text = StringUtils.replace(text, "${"+key+"}", value);
            if(key.indexOf(" ") == -1) {
                text = StringUtils.replace(text, "$"+key, value);
            }
        }
        return text;
    }

Hope that helps,

Hen

On Thu, 16 Jan 2003 scolebourne@btopenworld.com wrote:

> This method was removed for 1.0 due to its specific nature.
>
> Sorry.
>
> Stephen
>
> >  from:    Simon Moore <Si...@condisline.com>
> >  date:    Thu, 16 Jan 2003 11:10:59
> >  to:      commons-dev@jakarta.apache.org
> >  subject: Re: Where has commons lang Strings.interpolate(String text, Map map)  gone?
> >
> > > I've been cleaning up some alod code dependant on commons-lang 0.1-dev to
> > > depend on commons-lang 1.0 but I'm missing the
> > > Strings.interpolate(String text, Map map) in StringUtils???
> > >
> > > Does anyone know where it went?
> > >
> > > Regards,
> > >
> > >  Saimon
> > >
> > >
> >
> > --
> > To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> > For additional commands, e-mail: <ma...@jakarta.apache.org>
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>