Package org.mozilla.javascript

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


            // Previously mis-spelt as theadName
            scope.put("threadName", scope, Thread.currentThread().getName()); //$NON-NLS-1$
            scope.put("sampler", scope, currentSampler); //$NON-NLS-1$
            scope.put("sampleResult", scope, previousResult); //$NON-NLS-1$

            Object result = cx.evaluateString(scope, script, "<cmd>", 1, null); //$NON-NLS-1$

            resultStr = Context.toString(result);
            if (varName != null && vars != null) {// vars can be null if run from TestPlan
                vars.put(varName, resultStr);
            }
View Full Code Here


            cx.setGeneratingDebug(false);
            cx.setGeneratingSource(false);
            cx.setOptimizationLevel(0);
            cx.setDebugger(null, null);

            retval = cx.evaluateString(global, scriptText,
                                       source, lineNo,
                                       null);

            if (retval instanceof NativeJavaObject)
                retval = ((NativeJavaObject) retval).unwrap();
View Full Code Here

       
    try {
      Scriptable scope = new TopLevelFunctions(context, ctx, context.getDUDir());
      String source = element.getTextContent();
      VariableDelegator delegator = new VariableDelegator(scope, context, ctx);
      ctx.evaluateString(delegator, source, context.getActivityName(), 1, null);
      delegator.writeVariables();
    } catch (WrappedException e) {
      __logger.warn("Error during JS execution.", e);
      if (e.getWrappedException() instanceof FaultException) {
        throw (FaultException)e.getWrappedException();
View Full Code Here

        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw, true);
        ScriptableObject.putProperty(scope, "out", Context.javaToJS(pw, scope));
        final int lineNumber = 1;
        final Object securityDomain = null;
        rhinoContext.evaluateString(scope, jsCode, getClass().getSimpleName(),
                lineNumber, securityDomain);

        // check script output
        pw.flush();
        final String result = sw.toString().trim();
View Full Code Here

            // Previously mis-spelt as theadName
            scope.put("threadName", scope, Thread.currentThread().getName()); //$NON-NLS-1$
            scope.put("sampler", scope, currentSampler); //$NON-NLS-1$
            scope.put("sampleResult", scope, previousResult); //$NON-NLS-1$

            Object result = cx.evaluateString(scope, script, "<cmd>", 1, null); //$NON-NLS-1$

            resultStr = Context.toString(result);
            if (varName != null && vars != null) {// vars can be null if run from TestPlan
                vars.put(varName, resultStr);
            }
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, cond
            /** * conditionString ** */
            , "<cmd>", 1, null);
            resultStr = Context.toString(cxResultObject);

            if (resultStr.equals("false")) { //$NON-NLS-1$
View Full Code Here

    }
  public static Function createFunction(final String source, String name) {
    Context context = PersevereContextFactory.getContext();
    try {
      BaseFunction func = (BaseFunction) context.evaluateString(GlobalData.getGlobalScope(), "(" + source + ")", name, 1, null);
      // store the source so we can retain comments et al
      func.put("source", func, source);
      ScriptRuntime.setObjectProtoAndParent(func,GlobalData.getGlobalScope());
      return func;
    }
View Full Code Here

      ScriptRuntime.setObjectProtoAndParent(func,GlobalData.getGlobalScope());
      return func;
    }
    catch (Exception e) {
      System.err.println(e.getMessage());
      return (BaseFunction) context.evaluateString(GlobalData.getGlobalScope(), "(function(){throw new Error('Compilation error in this function')})", name, 1, null);
    }

    }
}
View Full Code Here

      Object result = null;
      cx.evaluateReader(scope, new BufferedReader(new InputStreamReader(
          getClass().getResourceAsStream("WikiFormatter.js"))),
          "WikiFormatter.js", 0, null);
      result = cx.evaluateString(scope,
          "new WikiFormatter().format(wikiText);", "<cmd>", 1, null);

      // Convert the result to a string and print it.
      return Context.toString(result);
View Full Code Here

    Context cx = Context.enter();
    cx.setOptimizationLevel(9);
    Global global = new Global();
    global.init(cx);
    Scriptable scope = cx.initStandardObjects(global);
    cx.evaluateString(scope, "var exports = {};", "exports", 1, null);
    cx.evaluateReader(scope, new InputStreamReader(cssmin.openConnection().getInputStream()), cssmin.getFile(), 1, null);
    Scriptable exports = (Scriptable) scope.get("exports", scope);
    Scriptable compressor = (Scriptable) exports.get("compressor", exports);
    Function fn = (Function) compressor.get("cssmin", compressor);
    content = ((String) Context.call(null, fn, compressor, compressor, new Object[] {
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.