commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Heuer <heue...@acm.org>
Subject RE: [lang] text.Interpolation, on to 2.2
Date Tue, 28 Jun 2005 18:39:07 GMT

Gary Gregory wrote:

> - (for me ;-) Provide an Interpolation feature that allows a simple way
> to use System properties to replace variables in a String. For me, this
> could be as simple as:
>
>    String s = XXX.resolveAll(source, "$", "{", "}",
> System.getProperties());

Maybe it is a bit of overkill, but you could use Velocity for this:

Velocity.init();
VelocityContext ctx = new VelocityContext(System.getProperties());
Template t = new Template(...);  // make a template from source
StringWriter sw = new StringWriter();
t.merge(ctx, sw);
String s = sw.toString();

Why reimplement something that already works quite well?

   michael


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


Mime
View raw message