NativeArray arr = (NativeArray) result; Object [] array = new Object[(int) arr.getLength()]; for (Object o : arr.getIds()) { int index = (Integer) o; array[index] = arr.get(index, null); }
@Override public Object call(Context cx, Scriptable scope, Scriptable thisObj, Object[] args) { if (args.length == 0) { throw new RuntimeException("'load' function takes at least one argument"); } for (Object arg : args) { if (arg instanceof NativeArray) { NativeArray array = (NativeArray)arg; for (int i = 0; i < array.getLength(); i++) { Object path = array.get(i); if (path != null) { load(path.toString(), cx, scope); } else { throw new NullPointerException("Cannot have null argument in load function"); } } } else if (arg == null) { throw new NullPointerException("Cannot have null argument in load function"); } else { load(arg.toString(), cx, scope); } } return null; }
Object[] params = new Object[]{numberOfWeeks, weeklyDisposable, easing, safetyZone, safetyZoneEasing, overSpentThisWeek}; // function doesn't return anything jsFunction.call(rhino, scope, scope, params); NativeArray resultArray = (NativeArray) scope.get("resultArray", scope); double result = ((Number) resultArray.get(numberOfWeeks)).getDoubleValue(); Log.d(TAG, "SKN-calculate3=" + result);
private static List<Object> asList(final NativeArray array) { final List<Object> list = new ArrayList<>((int)array.getLength()); for (final Object id : array.getIds()) { list.add(array.get((int)id, null)); } return list; } }
public Object get(int index) { return get((long) index); }
final Collection<Document> arrayResult = new ArrayList<>((int) nativeArray.getLength()); for (int i = 0; i < (int) nativeArray.getLength(); i++) { if (nativeArray.get(i, null) instanceof RhinoDocument) { final RhinoDocument rhinoDocument = (RhinoDocument) nativeArray.get(i, null); final Document document = rhinoDocument.toDocument( doc.getId(),
private static List<Object> asList(final NativeArray array) { final List<Object> list = new ArrayList<>((int)array.getLength()); for (final Object id : array.getIds()) { list.add(array.get((int)id, null)); } return list; } }
public Object get(int index) { return get((long) index); }
try (final WebClient webClient = new WebClient(BrowserVersion.CHROME)) { String url = "http://localhost/test.html"; HtmlPage htmlPage = webClient.getPage(url); NativeArray array = (NativeArray) htmlPage.executeJavaScript("arMailRuMessages").getJavaScriptResult(); for (int i = 0; i < array.getLength(); i++) { NativeObject object = (NativeObject) array.get(i); String id = (String) object.get("id"); System.out.println(id); NativeObject correspondents = (NativeObject) object.get("correspondents"); NativeArray from = (NativeArray) correspondents.get("from"); System.out.println(((NativeObject) from.get(0)).get("name")); } }
public Object next() { if (cursor == len) { throw new NoSuchElementException(); } return get(cursor++); }
public Object previous() { if (cursor == 0) { throw new NoSuchElementException(); } return get(--cursor); }
public Object previous() { if (cursor == 0) { throw new NoSuchElementException(); } return get(--cursor); }
public Object previous() { if (cursor == 0) { throw new NoSuchElementException(); } return get(--cursor); }
public Object next() { if (cursor == len) { throw new NoSuchElementException(); } return get(cursor++); }
public Object next() { if (cursor == len) { throw new NoSuchElementException(); } return get(cursor++); }
public Object previous() { if (cursor == 0) { throw new NoSuchElementException(); } return get(--cursor); }
public Object next() { if (cursor == len) { throw new NoSuchElementException(); } return get(cursor++); }
public Object[] toArray(Object[] a) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } int len = (int) longLen; Object[] array = a.length >= len ? a : (Object[]) java.lang.reflect.Array .newInstance(a.getClass().getComponentType(), len); for (int i = 0; i < len; i++) { array[i] = get(i); } return array; }
public Object[] toArray(Object[] a) { long longLen = length; if (longLen > Integer.MAX_VALUE) { throw new IllegalStateException(); } int len = (int) longLen; Object[] array = a.length >= len ? a : (Object[]) java.lang.reflect.Array .newInstance(a.getClass().getComponentType(), len); for (int i = 0; i < len; i++) { array[i] = get(i); } return array; }
public Object next() { Context.enter(); try { Object result = arr.get(index++, arr); return unwrap(result); } finally { Context.exit(); } }