Package org.mozilla.javascript

Examples of org.mozilla.javascript.Scriptable


                    "helma.scripting.rhino.extensions.XmlRpcObject", false);
            MailObject.init(global, app.getProperties());
            JSAdapter.init(context, global, false);

            // add some convenience functions to string, date and number prototypes
            Scriptable stringProto = ScriptableObject.getClassPrototype(global, "String");
            stringProto.put("trim", stringProto, new StringTrim());

            Scriptable dateProto = ScriptableObject.getClassPrototype(global, "Date");
            dateProto.put("format", dateProto, new DateFormat());

            Scriptable numberProto = ScriptableObject.getClassPrototype(global, "Number");
            numberProto.put("format", numberProto, new NumberFormat());

            Collection protos = app.getPrototypes();
            for (Iterator i = protos.iterator(); i.hasNext();) {
                Prototype proto = (Prototype) i.next();
                initPrototype(proto);
View Full Code Here


    * Check if an object has a function property (public method if it
    * is a java object) with that name.
    */
    public boolean hasFunction(String protoname, String fname) {
        // throws EvaluatorException if type has a syntax error
        Scriptable op = getValidPrototype(protoname);

        // if this is an untyped object return false
        if (op == null) {
            return false;
        }
View Full Code Here

                    ht.put(key, processXmlRpcResponse(prop.getValue()));
                }
            }
            return ht;
        } else if (arg instanceof Scriptable) {
            Scriptable s = (Scriptable) arg;
            if ("Date".equals(s.getClassName())) {
                return new Date((long) ScriptRuntime.toNumber(s));
            }
        }
        return arg;
    }
View Full Code Here

        Wrapper wrapper = ref == null ? null : (Wrapper) ref.get();

        if (wrapper == null || wrapper.unwrap() != e) {
            // Gotta find out the prototype name to use for this object...
            String prototypeName = app.getPrototypeName(e);
            Scriptable op = getPrototype(prototypeName);

            if (op == null) {
                // no prototype found, return an unscripted wrapper
                wrapper = new NativeJavaObject(global, e, e.getClass());
            } else {
View Full Code Here

        HopObject hobj = (HopObject) wrappercache.get(node);

        if (hobj == null) {
            String protoname = node.getPrototype();
            Scriptable op = getValidPrototype(protoname);

            // no prototype found for this node
            if (op == null) {
                // maybe this object has a prototype name that has been
                // deleted, but the storage layer was able to set a
View Full Code Here

     * Get a node wrapper for a node that may not have been fetched yet
     * @param handle a node handle
     * @return a wrapper for the node
     */
    public Scriptable getNodeWrapper(NodeHandle handle) {
        Scriptable hobj = (HopObject) wrappercache.get(handle);
        if (hobj != null) {
            return hobj;
        } else if (handle.hasNode()) {
            hobj = getNodeWrapper(handle.getNode(app.getWrappedNodeManager()));
        }

        if (hobj == null) {
            String protoName = handle.getKey().getStorageName();
            Scriptable op = getValidPrototype(protoName);

            // no prototype found for this node
            if (op == null) {
                protoName = "HopObject";
                op = getValidPrototype("HopObject");
View Full Code Here

                if (proto != null) {
                    skin = eng.getSkin(proto.getName(), hrefSkin);
                }

                if (skin != null) {
                    Scriptable param = Context.getCurrentContext().newObject(global);
                    param.put("path", param, href);
                    href = skin.renderAsString(eng.getRequestEvaluator(), handler, param).trim();
                    break;
                }

                handler = app.getParentElement(handler);
View Full Code Here

        app.setCurrentCodeResource(code);

        String encoding = app.getProperty("sourceCharset");

        try {
            Scriptable op = type.objProto;
            // do the update, evaluating the file
            if (sourceName.endsWith(".js")) {
                reader = encoding == null ?
                        new InputStreamReader(code.getInputStream()) :
                        new InputStreamReader(code.getInputStream(), encoding);
View Full Code Here

        String scriptStr = sb.toString();

        Context cx = Context.enter();
        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)) {
                        continue;
                    }
                    String id = (String)idObj;
                    if (!id.startsWith("WebServiceProvider")) {
                        continue;
                    }
                    Object obj = scriptScope.get(id, scriptScope);
                    if (!(obj instanceof Scriptable)) {
                        continue;
                    }
                    Scriptable wspVar = (Scriptable)obj;
                    providerFound = true;
                    obj = wspVar.get("ServiceMode", wspVar);
                    if (obj != Scriptable.NOT_FOUND) {
                        if (obj instanceof String) {
                            String value = (String)obj;
                            if ("PAYLOAD".equalsIgnoreCase(value)) {
                                mode = Service.Mode.PAYLOAD;
View Full Code Here

    public DOMSource invoke(DOMSource request) {
        DOMSource response = new DOMSource();
        Context cx = Context.enter();
        try {
            Scriptable scope = cx.newObject(scriptScope);
            scope.setPrototype(scriptScope);
            scope.setParentScope(null);
            Node node = request.getNode();
            Object inDoc = null;
            if (isE4X) {
                try {
                    Object xo = XmlObject.Factory.parse(node);
                    inDoc = Context.toObject(xo, scope);
                    Object[] args = {inDoc};
                    inDoc = cx.newObject(scriptScope, "XML", args);
                } catch (Exception ex) {
                    ex.printStackTrace();
                }
            } else {
                inDoc = Context.toObject(node, scope);
            }
            Object[] args = {inDoc};
            Object jsResp = invokeFunc.call(cx, scope, scope, args);
            if (isE4X) {
                // need to check return type and throw exception
                // if wrong type
                Scriptable s = (Scriptable)jsResp;
                Object out = ScriptableObject.callMethod(s,
                                                         "getXmlObject",
                                                         Context.emptyArgs);
                Wrapper wrapped = (Wrapper)out;
                XmlObject xml = (XmlObject)wrapped.unwrap();
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.Scriptable

Copyright © 2018 www.massapicom. 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.