Package javax.script

Examples of javax.script.CompiledScript.eval()


      if(bean!=null)
      {
      context.setAttribute( "this", bean, ScriptContext.ENGINE_SCOPE );
      context.setAttribute( "self", bean, ScriptContext.ENGINE_SCOPE );
      }
      Object res = cscript.eval(context);
      assertEquals( expr, expectedResult, res);
      return res;
    }
    catch(ScriptException ex)
    {
View Full Code Here


  public void doFailQuery( String expr )
  {
    CompiledScript cscript = compileScript(expr);
    try
    {
      Object res = cscript.eval(context);
      fail( "expr '" + expr + "' should fail (got '" + res + "')" );
    }
    catch(ScriptException ex)
    { // Should fail with this exception
    }
View Full Code Here

    {
     CompiledScript compiledScript = CompiledScriptFactory.getInstance().compileScript( "a", "rhino" );

     javax.script.Namespace context = compiledScript.getEngine().createNamespace();
     context.put( "a", new Integer(123));
     Object res = compiledScript.eval( context);

     assertNotNull("Result found", res);
     assertEquals("Result found", new Integer(123), res);
    }
View Full Code Here

        {
            try
            {
                Bindings binding = new SimpleBindings();
                binding.put("args", args);
                result = script.eval(binding);
            }
            catch(ScriptException ex)
            {
                logger_.warn(LogUtil.throwableToString(ex));
            }
View Full Code Here

                    String name = names.get(random.nextInt(names.size() - 1));
                    try {
                        final Bindings bindings = engine.createBindings();
                        bindings.put("g", g);
                        bindings.put("name", name);
                        Object result = script.eval(bindings);
                        if (name.equals("stephen") || name.equals("pavel") || name.equals("matthias"))
                            assertNull(result);
                        else
                            assertNotNull(result);
                    } catch (ScriptException e) {
View Full Code Here

        assertEquals("value",se.eval("key"));
        if (se instanceof Compilable){
            Compilable co = (Compilable) se;
            CompiledScript cs = co.compile("key");
            assertNotNull(cs);
            assertEquals("value",cs.eval());
            assertEquals("value",cs.eval());
        } else {
            fail("Expected engine to implement Compilable");
        }
    }
View Full Code Here

        if (se instanceof Compilable){
            Compilable co = (Compilable) se;
            CompiledScript cs = co.compile("key");
            assertNotNull(cs);
            assertEquals("value",cs.eval());
            assertEquals("value",cs.eval());
        } else {
            fail("Expected engine to implement Compilable");
        }
    }
View Full Code Here

                                            ((Compilable) scriptEngine).compile(fileReader);
                                    compiledScriptsCache.put(cacheKey, compiledScript);
                                }
                            }
                        }
                        return compiledScript.eval(bindings);
                    } else {
                        // TODO Charset ?
                        fileReader = new BufferedReader(new FileReader(scriptFile),
                                (int)scriptFile.length());
                        return scriptEngine.eval(fileReader, bindings);                   
View Full Code Here

                                    ((Compilable) scriptEngine).compile(getScript());
                            compiledScriptsCache.put(cacheKey, compiledScript);
                        }
                    }
                }
                return compiledScript.eval(bindings);
            } else {
                return scriptEngine.eval(getScript(), bindings);
            }
        } else {
            throw new ScriptException("Both script file and script text are empty for element:"+getName());           
View Full Code Here

          bind.put("current_page", model.getPage());
          bind.put("total_page", model.getTotalPage());
          bind.put("articles", model.getListResult());
          try {
            resp.getWriter().print((String) compiledscript.eval());
          } catch (Exception e) {
            e.printStackTrace();
            log.warning(e.toString());
          }
        } else {
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.