Package groovy.lang

Examples of groovy.lang.GroovyShell.evaluate()


            try {
                GroovyShell shell = new GroovyShell( binding );
                File groovyScript = Http.translatePath( groovyDir, request.getUrl() );
                if( groovyScript.exists() ) {
                    shell.evaluate( groovyScript.getAbsolutePath() );
                } else {
                    response.sendError( HttpURLConnection.HTTP_NOT_FOUND, request.getUrl() + " not found.");
                }
            } catch (ClassNotFoundException e) {
                log.log( Level.SEVERE, e.getMessage(), e );
View Full Code Here


    final GroovyShell interp = new GroovyShell(groovyBinding);
    boolean ret = true;

    try {
      final File f = new File(groovyScript);
      interp.evaluate(f);
    } catch (final Exception e) {
      logger.error("Exception while sourcing file " + groovyScript, e);
      setMessage(e.getMessage());
      ret = false;
    } catch (final Error e) {
View Full Code Here

    if (condString != null) {
      final GroovyShell interp = new GroovyShell(new Binding());
      String code = "import games.stendhal.server.entity.npc.condition.*;\r\n"
        + condString;
      try {
        condition = (ChatCondition) interp.evaluate(code);
      } catch (CompilationFailedException e) {
        throw new IllegalArgumentException(e);
      }
    }

View Full Code Here

    Binding groovyBinding = new Binding();
    final GroovyShell interp = new GroovyShell(groovyBinding);
    try {
      String code = "import games.stendhal.server.entity.npc.condition.*;\r\n"
        + value;
      return (ChatCondition) interp.evaluate(code);
    } catch (CompilationFailedException e) {
      throw new IllegalArgumentException(e);
    }
  }

View Full Code Here

    Binding groovyBinding = new Binding();
    final GroovyShell interp = new GroovyShell(groovyBinding);
    try {
      String code = "import games.stendhal.server.entity.npc.action.*;\r\n"
        + value;
      return (ChatAction) interp.evaluate(code);
    } catch (CompilationFailedException e) {
      throw new IllegalArgumentException(e);
    }
  }

View Full Code Here

    }
   
    @Test
    public void testEvaluateString() {
        GroovyShell shell = new GroovyShell();
        Object result = shell.evaluate("3+4");
        assertEquals(7, result);
    }
   
    @Test
    public void testLatLng() {
View Full Code Here

        binding.setVariable("street", "1600 Pennsylvania Avenue");
        binding.setVariable("city", "Washington");
        binding.setVariable("state", "DC");
        GroovyShell shell = new GroovyShell(binding);
        try {
            shell.evaluate(new File("src/geocodeV3.groovy"));
            assertEquals(38.898,
                Double.parseDouble((String) binding.getVariable("lat")),0.01);
            assertEquals(-77.037,
                Double.parseDouble((String) binding.getVariable("lng")),0.01);
        } catch (CompilationFailedException | IOException e) {
View Full Code Here

        binding.setVariable("street", "1600 Pennsylvania Avenue");
        binding.setVariable("city", "Washington");
        binding.setVariable("state", "DC");
        GroovyShell shell = new GroovyShell(binding);
        try {
            shell.evaluate(new File("src/geocodeV3.groovy"));
            assertEquals(38.898,
                Double.parseDouble((String) binding.getVariable("lat")),0.01);
            assertEquals(-77.037,
                Double.parseDouble((String) binding.getVariable("lng")),0.01);
View Full Code Here

            // Greenwich Observatory, Greenwich, England
            binding.setVariable("street", "Blackheath Avenue");
            binding.setVariable("city","Greenwich");
            binding.setVariable("state","UK");
            shell.evaluate(new File("src/geocodeV3.groovy"));
            assertEquals(51.476,
                    Double.parseDouble((String) binding.getVariable("lat")),0.01);
                assertEquals(0.001,
                    Double.parseDouble((String) binding.getVariable("lng")),0.01);
               
View Full Code Here

        binding.put("project", build.getParent());
        binding.put("rooturl", descriptor.getHudsonUrl());
        binding.put("logger", listener.getLogger());

        GroovyShell shell = createEngine(descriptor, binding);
        Object res = shell.evaluate(new InputStreamReader(scriptStream));
        if (res != null) {
            result = res.toString();
        }
        return result;
    }
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.