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


    protected Scriptable scope;

    public JSOMElementConvertor() {
        Context cx = Context.enter();
        try {
            this.scope = cx.initStandardObjects();
        } finally {
            Context.exit();
        }
    }
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

        }
        // entering a context
        Context ctx = enterContext();
        try {
            try {
                Scriptable scriptable = ctx.initStandardObjects(null, false);
                ScriptableObject.defineClass(scriptable, WindowWrapper.class);
            } catch (Exception e) {
                // cannot happen
            }
            // we now have the window object as the global object from the
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);
      Object result = cx.evaluateString(scope, script, "<cmd>", 1, null);

      resultStr = Context.toString( result );
      vars.put( varName, resultStr );
View Full Code Here

       
        if (_rootScope == null) {
            // Create it if never used up to now
            Context ctx = Context.enter();
            try {
                _rootScope = ctx.initStandardObjects(null);
                try {
                    ScriptableObject.defineClass(_rootScope, FOM_SimpleCocoon.class);
                } catch (Exception e) {
                    throw new CascadingRuntimeException("Cannot setup a root context with a cocoon object for javascript", e);
                }
View Full Code Here

       
        if (_rootScope == null) {
            // Create it if never used up to now
            Context ctx = Context.enter();
            try {
                _rootScope = ctx.initStandardObjects(null);
                try {
                    ScriptableObject.defineClass(_rootScope, FOM_SimpleCocoon.class);
                } catch (Exception e) {
                    throw new RuntimeException("Cannot setup a root context with a cocoon object for javascript", e);
                }
View Full Code Here

        String scriptStr = sb.toString();

        Context cx = ContextFactory.getGlobal().enterContext();
        boolean providerFound = false;
        try {
            Scriptable scriptScope = cx.initStandardObjects(null, true);
            Object[] ids = compileScript(cx, scriptStr, scriptScope, f);
            if (ids.length > 0) {
                Service.Mode mode = Service.Mode.PAYLOAD;
                for (Object idObj : ids) {
                    if (!(idObj instanceof String)) {
View Full Code Here

  public void testComment() {
    // //var one="1";
    // "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);
  }
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.