Package org.mozilla.javascript

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


        String resultStr = "";

        Context cx = Context.enter();
        try {

            Scriptable scope = cx.initStandardObjects(null);

            // Set up some objects for the script to play with
            scope.put("log", scope, log); //$NON-NLS-1$
            scope.put("ctx", scope, jmctx); //$NON-NLS-1$
            scope.put("vars", scope, vars); //$NON-NLS-1$
View Full Code Here


        boolean result = false;

        // 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);

View Full Code Here

      String directiveName, Iterable<String> toEscape, String soyUtilsPath)
      throws Exception {
    List<String> output = Lists.newArrayList();
    Context context = new ContextFactory().enterContext();
    context.setOptimizationLevel(-1)// Only running once.
    ScriptableObject globalScope = context.initStandardObjects();
    globalScope.defineProperty(
        "navigator", Context.javaToJS(new Navigator(), globalScope), ScriptableObject.DONTENUM);

    Reader soyutils = new InputStreamReader(new FileInputStream(soyUtilsPath), Charsets.UTF_8);
    try {
View Full Code Here

      }
      generatedJsExprsAsJsArray.append("]");

      Context context = new ContextFactory().enterContext();
      context.setOptimizationLevel(-1)// Only running once.
      ScriptableObject globalScope = context.initStandardObjects();
      NativeObject navigator = new NativeObject();
      ScriptableObject.putConstProperty(navigator, "userAgent", "testZilla");
      globalScope.defineProperty("navigator", navigator, ScriptableObject.DONTENUM);

      try {
View Full Code Here

        boolean result = false;

        // 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);

View Full Code Here

        String resultStr = "";

        Context cx = Context.enter();
        try {

            Scriptable scope = cx.initStandardObjects(null);

            // Set up some objects for the script to play with
            scope.put("log", scope, log); //$NON-NLS-1$
            scope.put("ctx", scope, jmctx); //$NON-NLS-1$
            scope.put("vars", scope, vars); //$NON-NLS-1$
View Full Code Here

    public static Scriptable getRootScope() {
        if (_rootScope == null) {
            // Create it if never used up to now
            Context ctx = Context.enter();
            try {
                _rootScope = ctx.initStandardObjects(null);
            } finally {
                Context.exit();
            }
        }
        return _rootScope;
View Full Code Here

        if (rootScope == null) {

            final Context rhinoContext = Context.enter();
            try {
               
                Scriptable tmpScope = rhinoContext.initStandardObjects(
                    new ImporterTopLevel(), false);
   
                // default classes
                addHostObjects(tmpScope,
                    (Class<? extends ScriptableObject>[]) HOSTOBJECT_CLASSES);
View Full Code Here

        // build the code, something like
        //  data = <jsonData> ;
        //  <code>
        final String jsCode = "data=" + jsonData + ";\n" + code;
        final Context rhinoContext = Context.enter();
        final ScriptableObject scope = rhinoContext.initStandardObjects();

        // execute the script, out script variable maps to sw
        final StringWriter sw = new StringWriter();
        final PrintWriter pw = new PrintWriter(sw, true);
        ScriptableObject.putProperty(scope, "out", Context.javaToJS(pw, scope));
View Full Code Here

    }
   
    Context cx = Context.enter();
    try {
      cx.setOptimizationLevel(-1);
      Scriptable scope = cx.initStandardObjects();
     
      _addAdHocSymbols(cx, scope);
     
      _loadEnvJsScript(cx, scope);
      _loadGaScript(cx, scope);
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.