Package org.mozilla.javascript

Examples of org.mozilla.javascript.Context.evaluateString()


    }

    public JsScriptEngine() {
        Context context = getContext();
        scope = new ImporterTopLevel(context); // so that we can use importPackage()
        context.evaluateString(scope, printSource, "print", 1, null); // so that we can print on std out

    }

    protected Object eval(String expr) {
        return jsEval(expr, "new String("+expr+")");
View Full Code Here


    // "success";
    String script = "//var one=\"1\";\n\"success\";";
    final Context cx = Context.enter();
    final Scriptable scope = cx.initStandardObjects();

    Object result = cx.evaluateString(scope, script, "test", 1, null);

    assertEquals("success", result);
  }

  @Test
View Full Code Here

      StringBuilder builder = new StringBuilder();
      while (s.hasNextLine()) {
        builder.append("\n").append(s.nextLine());
      }

      result = cx.evaluateString(scope, builder.toString(), "test", 1,
          null);
      s.close();
    } catch (FileNotFoundException e) {
      e.printStackTrace();
    }
View Full Code Here

        Object result = null;
       
        for (String resource : javascriptResources) {
          try {
            result = cx.evaluateString(scope,
            FileUtils.readWholeFileAsUTF8(this.getClass().getResourceAsStream(resource)).replaceAll("org", "xorg"),
            resource,
            1,
            (Object)null);
          } catch (NullPointerException e) {
View Full Code Here

          ttlString.replaceAll("org", "xorg").replaceAll("\\n","\\\\n").replaceAll("\\'","\\\\'").replaceAll("\\\\u", "\\\\\\\\u").replaceAll("\\\\U", "\\\\\\\\U") +
           "', '" + base + "'); debugOutput;";
        logger.debug(escapedString);
       
        result =
          cx.evaluateString(
            scope,
            escapedString,
            "file:///ttlString",
            1,
            (Object)null);
View Full Code Here

            (Object)null);

        logger.debug("debugOutput:\n" + result);
       
        result =
          cx.evaluateString(
            scope,
            testString.replaceAll("org", "xorg"),
            "file:///testString",
            1,
            (Object)null);
View Full Code Here

      Object result = null;
     
      for (String resource : javascriptResources) {
        try {
          result = cx.evaluateString(scope,
          FileUtils.readWholeFileAsUTF8(this.getClass().getResourceAsStream(resource)).replaceAll("org", "xorg"),
          resource,
          1,
          (Object)null);
        } catch (NullPointerException e) {
View Full Code Here

        "parseTtlToWalker('" + ttlString.replaceAll("org", "xorg") + "','file:///localhost/RhinoTest.java'); debugOutput;";
       
      logger.debug("Escaped String: " + escapedString);

      result =
        cx.evaluateString(
          scope,
          escapedString,
          "file:///ttlString",
          1,
          (Object)null);
View Full Code Here

          (Object)null);

      logger.debug(result);
     
      result =
        cx.evaluateString(
          scope,
          testString.replaceAll("org", "xorg"),
          "file:///testString",
          1,
          (Object)null);
View Full Code Here

      Object result = null;
     
      for (String resource : javascriptResources) {
        try {
          result = cx.evaluateString(scope,
          FileUtils.readWholeFileAsUTF8(this.getClass().getResourceAsStream(resource)).replaceAll("org", "xorg"),
          resource,
          1,
          (Object)null);
        } catch (NullPointerException e) {
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.