/** * @param name the name of the field to check * @return the first value found for the give name */ @JsxFunction({CHROME, FF}) public Scriptable getAll(final String name) { if (StringUtils.isEmpty(name)) { return Context.getCurrentContext().newArray(this, 0); } final List<Object> values = new ArrayList<>(); final Iterator<NameValuePair> iter = requestParameters_.iterator(); while (iter.hasNext()) { final NameValuePair pair = iter.next(); if (name.equals(pair.getName())) { values.add(pair.getValue()); } } final Object[] stringValues = values.toArray(new Object[values.size()]); return Context.getCurrentContext().newArray(this, stringValues); }
static void processFiles(Context cx, String[] args) { // define "arguments" array in the top-level object: // need to allocate new array since newArray requires instances // of exactly Object[], not ObjectSubclass[] Object[] array = new Object[args.length]; System.arraycopy(args, 0, array, 0, args.length); Scriptable argsObj = cx.newArray(global, array); global.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM); for (String file: fileList) { processSource(cx, file); } }
/** * @param name the name of the field to check * @return the first value found for the give name */ @JsxFunction({CHROME, FF}) public Scriptable getAll(final String name) { if (StringUtils.isEmpty(name)) { return Context.getCurrentContext().newArray(this, 0); } final List<Object> values = new ArrayList<>(); final Iterator<NameValuePair> iter = requestParameters_.iterator(); while (iter.hasNext()) { final NameValuePair pair = iter.next(); if (name.equals(pair.getName())) { values.add(pair.getValue()); } } final Object[] stringValues = values.toArray(new Object[0]); return Context.getCurrentContext().newArray(this, stringValues); }
public Object run(Context cx) { ScriptableObject global = getGlobal(cx); // get the command line arguments and define "arguments" // array in the top-level object Object[] argsCopy = new Object[args.length]; System.arraycopy(args, 0, argsCopy, 0, args.length); Scriptable argsObj = cx.newArray(global, argsCopy); global.defineProperty("arguments", argsObj, ScriptableObject.DONTENUM); script.exec(cx, global); return null; } });
array = new Object[0]; return context.newArray(thisObj, array);
/** * Returns an {@link Iterator} allowing to go through all key/value pairs contained in this object. * @return an {@link Iterator} */ @JsxFunction({CHROME, FF}) public Iterator entries() { final List<DomNode> elements = getElements(); final Context context = Context.getCurrentContext(); final Scriptable scope = getParentScope(); final List<Scriptable> list = new ArrayList<>(); for (int i = 0; i < elements.size(); i++) { final Object[] array = new Object[] {i, elements.get(i).getScriptableObject()}; list.add(context.newArray(scope, array)); } final Iterator object = new Iterator(ITERATOR_NAME, list.iterator()); object.setParentScope(scope); setIteratorPrototype(object); return object; }
/** * Returns an {@link Iterator} allowing to go through all key/value pairs contained in this object. * @return an {@link Iterator} */ @JsxFunction({CHROME, FF}) public Iterator entries() { final List<DomNode> elements = getElements(); final Context context = Context.getCurrentContext(); final Scriptable scope = getParentScope(); final List<Scriptable> list = new ArrayList<>(); for (int i = 0; i < elements.size(); i++) { final Object[] array = new Object[] {i, elements.get(i).getScriptableObject()}; list.add(context.newArray(scope, array)); } final Iterator object = new Iterator(ITERATOR_NAME, list.iterator()); object.setParentScope(scope); setIteratorPrototype(object); return object; }
array = new Object[0]; return context.newArray(thisObj, array);
final Scriptable response = cx.newArray(scope, groups.toArray());
final Scriptable response = cx.newArray(scope, groups.toArray());
final Scriptable response = cx.newArray(scope, groups.toArray());
final Scriptable response = cx.newArray(scope, groups.toArray());
final Scriptable response = cx.newArray(scope, groups.toArray());
public static Object enumId(Object enumObj, Context cx) { IdEnumeration x = (IdEnumeration)enumObj; if (x.iterator != null) { return x.currentId; } switch (x.enumType) { case ENUMERATE_KEYS: case ENUMERATE_KEYS_NO_ITERATOR: return x.currentId; case ENUMERATE_VALUES: case ENUMERATE_VALUES_NO_ITERATOR: return enumValue(enumObj, cx); case ENUMERATE_ARRAY: case ENUMERATE_ARRAY_NO_ITERATOR: Object[] elements = { x.currentId, enumValue(enumObj, cx) }; return cx.newArray(ScriptableObject.getTopLevelScope(x.obj), elements); default: throw Kit.codeBug(); } }
argsArray[1] = cx.newArray(calleeScope, elements);
ScriptableObject.DONTENUM); history = (NativeArray) cx.newArray(this, 0); defineProperty("history", history, ScriptableObject.DONTENUM);
Object[] copy = new Object[intLen]; System.arraycopy(na.dense, (int) begin, copy, 0, intLen); result = cx.newArray(scope, copy); } else { Scriptable resultArray = ScriptRuntime.newObject(cx, scope,