Package org.mozilla.javascript

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


    public static Schema fromValues(Scriptable scope, NativeObject values) {
        Context cx = getCurrentContext();
        Object[] names = values.getIds();
        Scriptable schemaConfig = cx.newObject(scope);
        Scriptable fields = cx.newArray(scope, names.length);
        for (int i=0; i<names.length; ++i) {
            String name = (String) names[i];
            Object jsValue = values.get(name, values);
            Object value = jsToJava(jsValue);
            String typeName = Field.getTypeName(value);
View Full Code Here


    }

    @JSGetter
    public NativeArray getEndPoints() {
        Context cx = getCurrentContext();
        return (NativeArray) cx.newArray(getParentScope(), new Object[] {getStartPoint(), getEndPoint()});
    }
   
    @JSFunction
    public LineString reverse() {
        return (LineString) GeometryWrapper.wrap(getParentScope(), getGeometry().reverse());
View Full Code Here

    public NativeArray getEndPoints() {
        Context cx = getCurrentContext();
        NativeArray components = getComponents();
        int size = components.size();
        Scriptable scope = getParentScope();
        NativeArray array = (NativeArray) cx.newArray(scope, 2*size);
        for (int i=0; i<size; ++i) {
            com.vividsolutions.jts.geom.LineString geom = (com.vividsolutions.jts.geom.LineString) components.get(i);
            LineString line = (LineString) GeometryWrapper.wrap(scope, geom);
            array.put(2*i, array, line.getStartPoint());
            array.put((2*i)+1, array, line.getEndPoint());
View Full Code Here

            for (Name name : names) {
                processNames.add(name.toString());
            }
        }
        Context context = getCurrentContext();
        return (NativeArray) context.newArray(
                ScriptRuntime.getTopCallScope(context), processNames.toArray());
    }
   
    @JSStaticFunction
    public static Process get(Scriptable processNameObj) {
View Full Code Here

        if (lengthObj != Context.getUndefinedValue()) {
            length = (int) Context.toNumber(lengthObj);
        }
        Context cx = getCurrentContext();
        Scriptable scope = getParentScope();
        NativeArray features = (NativeArray) cx.newArray(scope, length);
        Iterator iterator = (Iterator) __iterator__(true);
        int i=0;
        while (i<length && iterator.hasNext()) {
            features.put(i, features, iterator.next());
            ++i;
View Full Code Here

        Scriptable config = super.getConfig();

        // add features
        Context cx = getCurrentContext();
        Scriptable scope = getParentScope();
        Scriptable features = cx.newArray(scope, 0);
        SimpleFeatureIterator iterator = collection.features();
        int i = -1;
        while (iterator.hasNext()) {
            ++i;
            Feature feature = new Feature(scope, iterator.next());
View Full Code Here

    public NativeArray getCoordinates() {
        Context cx = getCurrentContext();
        Scriptable scope = getParentScope();
        com.vividsolutions.jts.geom.GeometryCollection geometry = (com.vividsolutions.jts.geom.GeometryCollection) getGeometry();
        int length = geometry.getNumGeometries();
        NativeArray array = (NativeArray) cx.newArray(scope, length);
        for (int i=0; i<length; ++i) {
            NativeArray coords = ((Geometry) GeometryWrapper.wrap(scope, geometry.getGeometryN(i))).getCoordinates();
            array.put(i, array, coords);
        }
        return array;
View Full Code Here

    public NativeArray getComponents() {
        Context cx = getCurrentContext();
        Scriptable scope = getParentScope();
        com.vividsolutions.jts.geom.GeometryCollection geometry = (com.vividsolutions.jts.geom.GeometryCollection) getGeometry();
        int length = geometry.getNumGeometries();
        NativeArray array = (NativeArray) cx.newArray(scope, length);
        for (int i=0; i<length; ++i) {
            array.put(i, array, GeometryWrapper.wrap(scope, geometry.getGeometryN(i)));
        }
        return array;
    }
View Full Code Here

            obj.delete("coordinates");
            NativeArray components = getComponents();
            int length = components.size();
            Context cx = getCurrentContext();
            Scriptable scope = getParentScope();
            Scriptable geometries = cx.newArray(scope, length);
            for (int i=0; i<length; ++i) {
                Geometry comp = (Geometry) components.get(i, components);
                geometries.put(i, geometries, comp.getConfig());
            }
            obj.put("geometries", obj, geometries);
View Full Code Here

     * @return
     */
    private static NativeArray listToJSArray(List<?> list, Scriptable scope) {
        int length = list.size();
        Context cx = getCurrentContext();
        NativeArray array = (NativeArray) cx.newArray(scope, length);
        for (int i=0; i<length; ++i) {
            array.put(i, array, javaToJS(list.get(i), scope));
        }
        return array;
    }
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.