Codota Logo
Script.evaluate
Code IndexAdd Codota 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)

  • Common ways to obtain Script
private void myMethod () {
Script s =
  • Codota IconGroovyShell shell;String scriptText;shell.parse(scriptText)
  • Codota IconClass scriptClass;(Script) scriptClass.newInstance()
  • Codota IconClass scriptClass;Binding context;InvokerHelper.createScript(scriptClass, context)
  • Smart code suggestions by Codota
}
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

  • Reading from database using SQL prepared statement
  • scheduleAtFixedRate (Timer)
  • onRequestPermissionsResult (Fragment)
  • getExternalFilesDir (Context)
  • Menu (java.awt)
  • MessageDigest (java.security)
    Uses a one-way hash function to turn an arbitrary number of bytes into a fixed-length byte sequence.
  • LinkedList (java.util)
    Doubly-linked list implementation of the List and Dequeinterfaces. Implements all optional list oper
  • Scanner (java.util)
    A parser that parses a text string of primitive types and strings with the help of regular expressio
  • Set (java.util)
    A collection that contains no duplicate elements. More formally, sets contain no pair of elements e1
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
Codota Logo
  • Products

    Search for Java codeSearch for JavaScript codeEnterprise
  • IDE Plugins

    IntelliJ IDEAWebStormAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogCodota Academy Plugin user guide Terms of usePrivacy policyJava Code IndexJavascript Code Index
Get Codota for your IDE now