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

javax0.jamal.groovy.GroovyEval Maven / Gradle / Ivy

The newest version!
package javax0.jamal.groovy;

import javax0.jamal.api.BadSyntax;
import javax0.jamal.api.InnerScopeDependent;
import javax0.jamal.api.Input;
import javax0.jamal.api.Macro;
import javax0.jamal.api.Processor;
import javax0.jamal.tools.Scanner;

public class GroovyEval implements Macro, InnerScopeDependent, Scanner {
    public String evaluate(Input in, Processor processor) throws BadSyntax {
        try {
            final var shell = Shell.getShell(in, processor, this);
            return "" + shell.evaluate(in.toString(), null);
        } catch (Exception e) {
            throw new BadSyntax("Error evaluating groovy script using eval", e);
        }
    }

    @Override
    public String getId() {
        return "groovy:eval";
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy