Scriptable wrappedElement = context.toObject(pathElem, global);
Scriptable wrappedElement = Context.toObject(pathElem, global);
    public void enterContext(HashMap globals) throws ScriptingException {        // set the thread filed in the FESI evaluator        // evaluator.thread = Thread.currentThread ();        // set globals on the global object        // context = Context.enter (context);        globals.putAll(extensionGlobals);        thread = Thread.currentThread();        if ((globals != null) && (globals != lastGlobals)) {            // loop through global vars and set them            for (Iterator i = globals.keySet().iterator(); i.hasNext();) {                String k = (String) i.next();                Object v = globals.get(k);                Scriptable scriptable = null;                try {                    // we do a lot of extra work to make access to global variables                    // comfortable to EcmaScript coders, i.e. we use a lot of custom wrappers                    // that expose properties and functions in a special way instead of just going                    // with the standard java object wrappers.                    if ("path".equals(k)) {                        Scriptable arr = context.newObject(global, "Array");                        List path = (List) v;                        // register path elements with their prototype                        for (int j = 0; j < path.size(); j++) {                            Object pathElem = path.get(j);                            Scriptable wrappedElement = context.toObject(pathElem, global);                            arr.put(j, arr, wrappedElement);                            String protoname = app.getPrototypeName(pathElem);                            if (protoname != null) {                                arr.put(protoname, arr, wrappedElement);                            }                        }                        v = arr;                    }                    scriptable = context.toObject(v, global);                    global.put(k, global, scriptable);                } catch (Exception x) {                    app.logEvent("Error setting global variable " + k + ": " + x);                }            }        }        // remember the globals set on this evaluator        lastGlobals = globals;    }