Package org.mozilla.javascript

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


                                   });


                Object[] objs = new Object[paths.size()];
                paths.toArray(objs);
                Scriptable fileList = cx.newArray(this, objs);
                if (log.isDebugEnabled()) {
                    log.debug("readdir({}) = {}", dn, objs.length);
                }
                return new Object[] { Context.getUndefinedValue(), fileList };
View Full Code Here


                        }

                        // Return as an array, possibly empty
                        Object[] rowArray = rows.toArray(new Object[rows.size()]);
                        self.runtime.enqueueCallback(cb, cb, self, domain, new Object[] {
                            Undefined.instance, cx.newArray(self, rowArray), (rowCount < maxRows)
                        });

                    } catch (final SQLException sqle) {
                        self.runtime.enqueueTask(new ScriptTask() {
                            @Override
View Full Code Here

            try {
                File f = translatePath(dn);
                String[] files = f.list();
                Scriptable fileList;
                if (files == null) {
                    fileList = cx.newArray(this, 0);
                } else {
                    Object[] objs = new Object[files.length];
                    System.arraycopy(files, 0, objs, 0, files.length);
                    fileList = cx.newArray(this, objs);
                }
View Full Code Here

                if (files == null) {
                    fileList = cx.newArray(this, 0);
                } else {
                    Object[] objs = new Object[files.length];
                    System.arraycopy(files, 0, objs, 0, files.length);
                    fileList = cx.newArray(this, objs);
                }
                return new Object[] { Context.getUndefinedValue(), fileList };
            } finally {
                Context.exit();
            }
View Full Code Here

  }
 
  private Scriptable createNodeArray(Object[] nodes) {
    final Scriptable scope = ScriptableObject.getTopLevelScope(this);
    final Context cx = Context.getCurrentContext();
    Scriptable array =  cx.newArray(scope, nodes);
    exportObject(array);
    return array;
  }
 
  public Scriptable jsGet_attributes() {
View Full Code Here

  }

  private Object headersToJS(Header[] headers) {
    final Scriptable scope = ScriptableObject.getTopLevelScope(this);
    final Context cx = Context.getCurrentContext();
    final Scriptable array = cx.newArray(scope, headers.length);
    for(int i = 0; i < headers.length; i++) {
      array.put(i, array, Context.javaToJS(headers[i], scope));
    }
    return array;
  }
View Full Code Here

  }
 
  private Object cookiesToJS(List<IHttpResponseCookie> cookies) {
    final Scriptable scope = ScriptableObject.getTopLevelScope(this);
    final Context cx = Context.getCurrentContext();
    final Scriptable array = cx.newArray(scope, cookies.size());
    for(int i = 0; i < cookies.size(); i++) {
      array.put(i, array, Context.javaToJS(cookies.get(i), scope));
    }
    return array;
  }
View Full Code Here

    private void executeScript(Object[] scriptArgs) throws IOException, JavaScriptException {
        try {
            Context ctxt = Context.enter();
            File scriptFile = new File(scriptName);

            Scriptable argsObj = ctxt.newArray(scope, scriptArgs);
            scope.defineProperty("arguments", argsObj,
                    ScriptableObject.DONTENUM);

            msgEntry.setAppContext("executeScript()");
            msgEntry.appendMessageText("Executing Rhino JS script " + scriptFile.getAbsolutePath());
View Full Code Here

            } else {
              final int length = optionArgs.length - 1;
                array = new Object[length];
                System.arraycopy(optionArgs, 1, array, 0, length);
            }
            final Scriptable argsObj = context.newArray(shell, array);
            shell.defineProperty("arguments", argsObj,
                                 ScriptableObject.DONTENUM);

            shell.processSource(context, optionArgs.length == 0 ? null : optionArgs[0]);
        } finally {
View Full Code Here

    private static Object getValue(DatabaseHostObject db, ResultSet results, int index, int type) throws SQLException, ScriptException {
        Context cx = db.context;
        //TODO : implement for other sql types
        switch (type) {
            case Types.ARRAY:
                return (results.getArray(index) == null) ? null : cx.newArray(db, new Object[]{results.getArray(index)});
            case Types.BIGINT:
                return (results.getBigDecimal(index) == null) ? null : results.getBigDecimal(index).toPlainString();
            case Types.BINARY:
            case Types.LONGVARBINARY:
                return results.getBinaryStream(index) == null ? null : cx.newObject(db, "Stream", new Object[]{results.getBinaryStream(index)});
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.