Package org.mozilla.javascript

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


                scope.put("XSCRIPTCONTEXT", scope, jsCtxt);

                Scriptable jsArgs = Context.toObject(params, scope);
                scope.put("ARGUMENTS", scope, jsArgs);

                result = ctxt.evaluateString(scope,
                        source, "<stdin>", 1, null);
                result = ctxt.toString(result);
        return result;
            }
            catch (JavaScriptException jse) {
View Full Code Here


      // now evaluate the condition using JavaScript
      Context cx = Context.enter();
      try {
          Scriptable scope = cx.initStandardObjects(null);
          Object cxResultObject =
            cx.evaluateString(scope, getCondition()
          /*** conditionString ***/
          , "<cmd>", 1, null);
          resultStr = Context.toString(cxResultObject);

          if (resultStr.equals("false")) {
View Full Code Here

        Context cx = Context.enter();
        try
        {

            Scriptable scope = cx.initStandardObjects(null);
            Object result = cx.evaluateString(scope, script, "<cmd>", 1, null);

            resultStr = Context.toString(result);
            vars.put(varName, resultStr);

        }
View Full Code Here

            compileScope.setParentScope(coffeeScript);
            compileScope.put("coffeeScript", compileScope, coffeeScriptSource);
            try {
                boolean useMap = map != SourceMap.NONE;
                String options = String.format("{bare: %s, sourceMap: %s, literate: %s, header: %s, filename: '%s'}", bare, useMap, literate, header, sourceName);
                Object result = context.evaluateString(
                        compileScope,
                        String.format("compile(coffeeScript, %s);", options),
                        sourceName, 0, null);

                if (map == SourceMap.NONE) {
View Full Code Here

           
            for(String name : objectsToPutInScope.keySet()) {
                compileScope.put( name, compileScope, objectsToPutInScope.get( name ));
            }
           
            return (String)context.evaluateString(
                    compileScope,
                    scriptString,
                    sourceName, 0, null);
           
        } finally {
View Full Code Here

    final Context context = Context.enter();
    try {
      final ScriptableObject scope = (ScriptableObject) context
          .initStandardObjects(this.moduleScope);

      final Object result = context.evaluateString(scope,
          String.format(this.source, data), this.name, 1, null);

      output.append(String.valueOf(result));
    } catch (final JavaScriptException e) {
      throw new SmallerException("Failed to run javascript", e);
View Full Code Here

      final ContextFactory contextFactory = new ContextFactory();
      final Context context = contextFactory.enterContext();
      final Scriptable scope = context.initStandardObjects();
      wrapper = initializeScope(scope);

      final Object o = context.evaluateString(scope, expression, getName(), 1, null);
      if (o instanceof NativeJavaObject)
      {
        final NativeJavaObject object = (NativeJavaObject) o;
        return object.unwrap();
      }
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

          System.out.println("Failed to load " + resource);
        }
      }
     
      result =
        cx.evaluateString(
          scope,
          "parseTtlToWalker('" + ttlString.replaceAll("org", "xorg") + "','file:///localhost/RhinoTest.java');",
          "file:///ttlString",
          1,
          (Object)null);
View Full Code Here

          "file:///ttlString",
          1,
          (Object)null);

      result =
        cx.evaluateString(
          scope,
          testString.replaceAll("org", "xorg"),
          "file:///testString",
          1,
          (Object)null);
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.