Package org.mozilla.javascript

Examples of org.mozilla.javascript.NativeObject


   
    @JSGetter
    public NativeObject getProperties() {
        Context cx = getCurrentContext();
        Scriptable scope = getParentScope();
        NativeObject properties = (NativeObject) cx.newObject(scope);
        for (Property property : feature.getProperties()) {
            String name = property.getName().toString();
            properties.put(name, properties, get(name));
        }
        return properties;
    }
View Full Code Here


        }
        return new Feature(getTopLevelScope(featureObj), feature);
    }

    public String toFullString() {
        NativeObject properties = getProperties();
        Object[] names = properties.getIds();
        String repr = "";
        int length = names.length;
        for (int i=0; i<length; ++i) {
            String name = (String) names[i];
            Object value = get(name);
View Full Code Here

            throw ScriptRuntime.constructError("Error", "Constructor takes a single argument");
        }
        FeatureCollection collection = null;
        Object arg = args[0];
        if (arg instanceof NativeObject) {
            NativeObject config = (NativeObject) arg;
            if (inNewExpr) {
                collection = new FeatureCollection(config);
            } else {
                collection = new FeatureCollection(config.getParentScope(), config);
            }
        } else if (arg instanceof NativeArray) {
            NativeArray array = (NativeArray) arg;
            if (inNewExpr) {
                collection = new FeatureCollection(array);
View Full Code Here

                ++current;
                Object obj = array.get(current, array);
                if (obj instanceof Feature) {
                    feature = (SimpleFeature) ((Feature) obj).unwrap();
                } else if (obj instanceof NativeObject) {
                    NativeObject config = (NativeObject) obj;
                    feature = (SimpleFeature) new Feature(config.getParentScope(), config).unwrap();
                } else {
                    throw new NoSuchElementException("Expected a feature instance at index " + current);
                }
            } else {
                throw new NoSuchElementException("hasNext() returned false!");
View Full Code Here

        Context context = Context.getCurrentContext();
        if (context == null) {
            throw ScriptRuntime.constructError("Error",
                    "No context associated with current thread");
        }
        NativeObject wkt = (NativeObject) context.newObject(scope);
        wkt.defineFunctionProperties(new String[] { "read", "write" },
                WKT.class, ScriptableObject.PERMANENT);
        return wkt;
    }
View Full Code Here

        } catch (ParseException e) {
            throw ScriptRuntime.constructError("Error", e.getMessage());
        }
        Object result;
        if (parsed instanceof NativeObject) {
            NativeObject obj = (NativeObject) parsed;
            result = readObj(obj);
        } else {
            throw ScriptRuntime.constructError("Error", "Expected a string representing a JSON object, got " + Context.toString(parsed));
        }
        return result;
View Full Code Here

        Context context = Context.getCurrentContext();
        if (context == null) {
            throw ScriptRuntime.constructError("Error",
                    "No context associated with current thread");
        }
        NativeObject json = (NativeObject) context.newObject(scope);
        json.defineFunctionProperties(new String[] { "read", "write" },
                JSON.class, ScriptableObject.PERMANENT);
        return json;
    }
View Full Code Here

     * @param scope
     * @return
     */
    public static NativeObject mapToJSObject(Map<?, ?> map, Scriptable scope) {
        Context context = getCurrentContext();
        NativeObject obj = (NativeObject) context.newObject(scope);
        for (Object id  : map.keySet()) {
            obj.put(id.toString(), obj, javaToJS(map.get(id), scope));
        }
        return obj;
    }
View Full Code Here

            this.content = content;
            this.windowWrapper = ww;
        }

        public Object[] buildArguments() {
            ScriptableObject so = new NativeObject();
            so.put("success", so,
                   (success) ? Boolean.TRUE : Boolean.FALSE);
            if (mime != null) {
                so.put("contentType", so,
                       Context.toObject(mime, windowWrapper));
            }
            if (content != null) {
                so.put("content", so,
                       Context.toObject(content, windowWrapper));
            }
            return new Object [] { so };
        }
View Full Code Here

                    (object, COMPLETE,
                     new RhinoInterpreter.ArgumentsBuilder() {
                         public Object[] buildArguments() {
                             Object[] arguments = new Object[1];
                             ScriptableObject so =
                                 new NativeObject();
                             so.put("success", so,
                                    (success) ?
                                    Boolean.TRUE : Boolean.FALSE);
                             if (mime != null) {
                                 so.put("contentType", so,
                                        Context.toObject(mime, scope));
                             }
                             if (content != null) {
                                 so.put("content", so,
                                        Context.toObject(content, scope));
                             }
                             arguments[0] = so;
                             return arguments;
                         }
View Full Code Here

TOP

Related Classes of org.mozilla.javascript.NativeObject

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.