« Return to Thread: Evaluating a GString
glaforge wrote:Have you looked at the Eval class?
http://groovy.codehaus.org/api/groovy/util/Eval.html
On Mon, Oct 27, 2008 at 12:19 PM, melix <cedric.champeau@lingway.com> wrote:
> Hi,
>
> I'm trying to find out if there's any shorter way to evaluate a GString from
> Java code. The string to be evaluated comes from an XML configuration file
> and includes placeholders. My solution seems rather complex for such a basic
> need, and I'm quite sure there are situations where it doesn't work properly
> :
>
> Binding binding = new Binding();
> ...
> String evaluatedRegex = "\""+
> org.apache.commons.lang.StringEscapeUtils.escapeJava(regex)+"\"";
> evaluatedRegex = new
> GroovyShell(binding).evaluate(evaluatedRegex).toString();
>
> I'd like to be able to write something like :
>
> String evaluatedRegex = new GString(regex, binding).toString();
>
> Or (cleaner) :
>
> String evaluatedRegex = GStringFactory.evaluate(regex, binding);
>
> Thanks
> ________________________________
> View this message in context: Evaluating a GString
> Sent from the groovy - user mailing list archive at Nabble.com.
>
--
Guillaume Laforge
Groovy Project Manager
G2One, Inc. Vice-President Technology
http://www.g2one.com
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
« Return to Thread: Evaluating a GString
| Free embeddable forum powered by Nabble | Forum Help |