Package javax.script

Examples of javax.script.CompiledScript.eval()


            bind.put("articles", listResult);
            bind.put("current_page", page);

            try {
              resp.getWriter().print(
                  (String) compiledscript.eval());
            } catch (Exception e) {
              e.printStackTrace();
              log.warning(e.toString());
            }
          } else {
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

                RecentViewHelper.getRecentView());
            bind.put("list_tag", tagModel.getListResult());
            bind.put("list_category", cateModel.getListResult());
            bind.put("article", obj);
            try {
              String result = (String) compiledscript.eval();
              treeCache.put(alias, result);
              resp.getWriter().print(result);
            } catch (Exception e) {
              e.printStackTrace();
              log.warning(e.toString());
View Full Code Here

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

                                        ((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

            "def get_perimeter(x, y)\n" +
              "x + 2.0 * y + Math::PI / 2.0 * x\n" +
            "end\n" +
            "norman_window(2, 1)";
        CompiledScript cs = ((Compilable)instance).compile(script);
        List<Double> result = (List<Double>) cs.eval();
        assertEquals(3.570796327, result.get(0), 0.000001);
        assertEquals(7.141592654, result.get(1), 0.000001);

        instance.getBindings(ScriptContext.ENGINE_SCOPE).clear();
        instance = null;
View Full Code Here

        String filename = basedir + "/test/org/jruby/embed/ruby/proverbs_of_the_day.rb";
        Reader reader = new FileReader(filename);
       
        instance.put("$day", -1);
        CompiledScript cs = ((Compilable)instance).compile(reader);
        String result = (String) cs.eval();
        String expResult = "A rolling stone gathers no moss.";
        assertEquals(expResult, result);
        result = (String) cs.eval();
        expResult = "A friend in need is a friend indeed.";
        assertEquals(expResult, result);
View Full Code Here

        instance.put("$day", -1);
        CompiledScript cs = ((Compilable)instance).compile(reader);
        String result = (String) cs.eval();
        String expResult = "A rolling stone gathers no moss.";
        assertEquals(expResult, result);
        result = (String) cs.eval();
        expResult = "A friend in need is a friend indeed.";
        assertEquals(expResult, result);
        result = (String) cs.eval();
        expResult = "Every garden may have some weeds.";
        assertEquals(expResult, 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.