All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.coherentlogic.fred.client.webstart.application.GroovyEngine Maven / Gradle / Ivy

Go to download

This application demonstrates how to use the FRED Client and allows the developer to write custom queries via the FRED Client API.

There is a newer version: 1.0.11-RELEASE
Show newest version
package com.coherentlogic.fred.client.webstart.application;

import groovy.lang.Binding;
import groovy.lang.GroovyShell;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * This class takes care of executing the Groovy script that is entered in the
 * input text area in the {@link FREDClientGUI}.
 *
 * @author Support
 */
public class GroovyEngine {

    private static final Logger log =
        LoggerFactory.getLogger(GroovyEngine.class);

    private final GroovyShell groovyShell;

    public GroovyEngine (Binding binding) {
        this (
            new GroovyShell (binding)
        );
    }

    public GroovyEngine (GroovyShell groovyShell) {
        this.groovyShell = groovyShell;
    }

    public void setVariable (String name, Object value) {
        this.groovyShell.setVariable(name, value);
    }

    public Object evaluate (String scriptText) {

        log.info("scriptText: " + scriptText);

        Object result = groovyShell.evaluate(scriptText);

        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy