Wie, um eine Liste aller binding-Variablen mit der GroovyShell

Ich bin sehr neu in Groovy. Wie kann ich eine Liste aller Variablen, die ich übergeben, um die Bindung Konstruktor ?

Erwägung habe ich folgende :

@Test
public void test() {

    List<String> outputNames = Arrays.asList("returnValue", "ce");

    String script = getScript();
    Script compiledScript = compileScript(script);
    CustomError ce = new CustomError("shit", Arrays.asList(new Long(1)));

    Map<String, Object> inputObjects = new HashMap<String, Object>();
    inputObjects.put("input", "Hovada");
    inputObjects.put("error", ce);

    Binding binding = new Binding(inputObjects);
    compiledScript.setBinding(binding);
    compiledScript.run();

    for (String outputName : outputNames) {
        System.out.format("outputName : %s  =  %s", outputName, binding.getVariable(outputName));
    }
}

private Script compileScript(String script) {
    GroovyShell groovyShell = new GroovyShell();
    Script compiledScript = groovyShell.parse(script);
    return compiledScript;
}

Wie kann ich die Iteration über alle Variablen (über die hashMap) in groovy.Skript ?

InformationsquelleAutor lisak | 2011-09-14
Schreibe einen Kommentar