Package org.mozilla.javascript

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


        public XLoper execute(IFunctionContext context, XLoper[] args) throws RequestException {
            Context ctx = Context.enter();
            Object[] oargs = converter.convert(args, BSFScript.createArgHints(args));
            ScriptableObject so = ctx.initStandardObjects();
            Scriptable argsObj = ctx.newArray(so, oargs);
            so.defineProperty("args", argsObj, ScriptableObject.DONTENUM);
            try {
                return converter.createFrom(script.exec(ctx, so));
            } catch (Throwable t) {
                throw new RequestException(t.getMessage());
View Full Code Here


            } else {
                int length = args.length;
                array = new Object[length];
                System.arraycopy(args, 0, array, 0, length);
            }
            Scriptable argsObj = cx.newArray(runner, array);
           
            runner.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM);
           
            for(String key : globalVariables.keySet()) {
                runner.defineProperty(key, globalVariables.get( key ), ScriptableObject.DONTENUM);
View Full Code Here

              // may have other issues too. Let's just copy the array and wrap that.
              final Object[] arrayAsObjectArray = new Object[Array.getLength(arg)];
              for (int j = 0; j < Array.getLength(arg); j++) {
                arrayAsObjectArray[j] = Array.get(arg, j);
              }
              args[i + 1] = cx.newArray(scope, arrayAsObjectArray);
            } else {
              args[i + 1] = Context.javaToJS(arg, scope);
            }
          }
        }
View Full Code Here

   
    @JSFunction
    public NativeArray toArray() {
        Context cx = getCurrentContext();
        Scriptable scope = getParentScope();
        return (NativeArray) cx.newArray(scope, new Object[] {getMinX(), getMinY(), getMaxX(), getMaxY()});
    }
   
    @JSFunction
    public Bounds clone() {
        ReferencedEnvelope clone = new ReferencedEnvelope(refEnv);
View Full Code Here

        Scriptable scope = getParentScope();
        Context cx = getCurrentContext();
        Object[] elements = new Object[] {
                coord.x, coord.y
        };
        NativeArray array = (NativeArray) cx.newArray(scope, elements);
        double z = coord.z;
        if (!Double.isNaN(z)) {
            array.put(2, array, z);
        }
        return array;
View Full Code Here

     */
    protected NativeArray coordsToArray(Coordinate[] coords) {
        Scriptable scope = getParentScope();
        Context cx = getCurrentContext();
        int length = coords.length;
        NativeArray array = (NativeArray) cx.newArray(scope, length);
        for (int i=0; i<length; ++i) {
            array.put(i, array, coordToArray(coords[i]));
        }
        return array;
    }
View Full Code Here

    public NativeArray getCoordinates() {
        Context cx = getCurrentContext();
        Scriptable scope = getParentScope();
        com.vividsolutions.jts.geom.Polygon poly = (com.vividsolutions.jts.geom.Polygon) getGeometry();
        int length = 1 + poly.getNumInteriorRing();
        NativeArray array = (NativeArray) cx.newArray(scope, length);
        array.put(0, array, coordsToArray(poly.getExteriorRing().getCoordinates()));
        for (int i=1; i<length; ++i) {
            array.put(i, array, coordsToArray(poly.getInteriorRingN(i-1).getCoordinates()));
        }
        return array;
View Full Code Here

    public NativeArray getFields() {
        Scriptable scope = getParentScope();
        Context cx = getCurrentContext();
        List<AttributeDescriptor> descriptors = featureType.getAttributeDescriptors();
        int length = descriptors.size();
        NativeArray array = (NativeArray) cx.newArray(scope, length);
        for (int i=0; i<length; ++i) {
            array.put(i, array, new Field(scope, descriptors.get(i)));
        }
        return array;
    }
View Full Code Here

    public NativeArray getFieldNames() {
        Scriptable scope = getParentScope();
        Context cx = getCurrentContext();
        List<AttributeDescriptor> descriptors = featureType.getAttributeDescriptors();
        int length = descriptors.size();
        NativeArray array = (NativeArray) cx.newArray(scope, length);
        for (int i=0; i<length; ++i) {
            array.put(i, array, descriptors.get(i).getLocalName());
        }
        return array;
    }
View Full Code Here

        Scriptable config = super.getConfig();
        Scriptable scope = getParentScope();
        Context cx = getCurrentContext();
        List<AttributeDescriptor> descriptors = featureType.getAttributeDescriptors();
        int length = descriptors.size();
        NativeArray array = (NativeArray) cx.newArray(scope, length);
        for (int i=0; i<length; ++i) {
            Field field = new Field(scope, descriptors.get(i));
            field.getConfig();
            array.put(i, array, field.getConfig());
        }
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.