congrats Icon
New! Announcing our next generation AI code completions
Read here
Tabnine Logo
Script.evaluate
Code IndexAdd Tabnine to your IDE (free)

How to use
evaluate
method
in
groovy.lang.Script

Best Java code snippets using groovy.lang.Script.evaluate (Showing top 2 results out of 315)

origin: bonitasoft/bonita-engine

@Override
public Object evaluate(final SExpression expression, final Map<String, Object> context, final Map<Integer, Object> resolvedExpressions,
    final ContainerState containerState) throws SExpressionEvaluationException {
  final String expressionContent = expression.getContent();
  final ClassLoader scriptClassLoader = Thread.currentThread().getContextClassLoader();
  final String expressionName = expression.getName();
  try {
    final GroovyShell shell = new GroovyShell(scriptClassLoader);
    // can put the name here
    final Script script = shell.parse(expressionContent);
    final Binding binding = new Binding(context);
    script.setBinding(binding);
    return script.evaluate(expressionContent);
  } catch (final MissingPropertyException e) {
    final String property = e.getProperty();
    final StringBuilder builder = new StringBuilder("Expression ");
    builder.append(expressionName).append(" with content: ").append(expressionContent).append(" depends on ").append(property)
        .append(" is neither defined in the script nor in dependencies");
    throw new SExpressionEvaluationException(builder.toString(), e, expressionName);
  } catch (final GroovyRuntimeException e) {
    throw new SExpressionEvaluationException(e, expressionName);
  } catch (final Exception e) {
    throw new SExpressionEvaluationException("Script throws an exception" + expression, e, expressionName);
  }
}
origin: bonitasoft/bonita-engine

@Override
public Object evaluate(final SExpression expression, final Map<String, Object> context, final Map<Integer, Object> resolvedExpressions,
    final ContainerState containerState) throws SExpressionEvaluationException {
  final String expressionContent = expression.getContent();
  final ClassLoader scriptClassLoader = Thread.currentThread().getContextClassLoader();
  final String expressionName = expression.getName();
  try {
    final GroovyShell shell = new GroovyShell(scriptClassLoader);
    // can put the name here
    final Script script = shell.parse(expressionContent);
    final Binding binding = new Binding(context);
    script.setBinding(binding);
    return script.evaluate(expressionContent);
  } catch (final MissingPropertyException e) {
    final String property = e.getProperty();
    final StringBuilder builder = new StringBuilder("Expression ");
    builder.append(expressionName).append(" with content: ").append(expressionContent).append(" depends on ").append(property)
        .append(" is neither defined in the script nor in dependencies");
    throw new SExpressionEvaluationException(builder.toString(), e, expressionName);
  } catch (final GroovyRuntimeException e) {
    throw new SExpressionEvaluationException(e, expressionName);
  } catch (final Exception e) {
    throw new SExpressionEvaluationException("Script throws an exception" + expression, e, expressionName);
  }
}
groovy.langScriptevaluate

Javadoc

A helper method to allow the dynamic evaluation of groovy expressions using this scripts binding as the variable scope

Popular methods of Script

  • run
    A helper method to allow scripts to be run taking command line arguments
  • setBinding
  • getProperty
  • getBinding
  • setProperty
  • invokeMethod
    Invoke a method (or closure in the binding) defined.
  • getMetaClass
  • setMetaClass

Popular in Java

  • Running tasks concurrently on multiple threads
  • setRequestProperty (URLConnection)
  • runOnUiThread (Activity)
  • onRequestPermissionsResult (Fragment)
  • HttpURLConnection (java.net)
    An URLConnection for HTTP (RFC 2616 [http://tools.ietf.org/html/rfc2616]) used to send and receive d
  • Calendar (java.util)
    Calendar is an abstract base class for converting between a Date object and a set of integer fields
  • Random (java.util)
    This class provides methods that return pseudo-random values.It is dangerous to seed Random with the
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • ServletException (javax.servlet)
    Defines a general exception a servlet can throw when it encounters difficulty.
  • FileUtils (org.apache.commons.io)
    General file manipulation utilities. Facilities are provided in the following areas: * writing to a
  • 21 Best Atom Packages for 2021
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyStudentsTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now