equal
deleted
inserted
replaced
|
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
|
2 // Use of this source code is governed by a BSD-style license that can be |
|
3 // found in the LICENSE file. |
|
4 |
|
5 package org.chromium.sdk; |
|
6 |
|
7 import java.util.SortedMap; |
|
8 |
|
9 import org.chromium.sdk.internal.tools.v8.MethodIsBlockingException; |
|
10 |
|
11 /** |
|
12 * This interface adds methods for handling array elements to the JsObject. |
|
13 */ |
|
14 public interface JsArray extends JsObject { |
|
15 |
|
16 /** |
|
17 * @return the array length (index of the last element plus one), |
|
18 * 0 iff the array is empty |
|
19 */ |
|
20 int length(); |
|
21 |
|
22 /** |
|
23 * @param index in the array |
|
24 * @return a {@code JsVariable} at the {@code index}, or {@code null} if there |
|
25 * is no value at the specified index in the array |
|
26 * @throws MethodIsBlockingException if called from a callback because it may |
|
27 * need to load element data from remote |
|
28 */ |
|
29 JsVariable get(int index) throws MethodIsBlockingException; |
|
30 |
|
31 /** |
|
32 * @return a map whose keys are array indices and values are {@code |
|
33 * JsVariable} instances found at the corresponding indices. The |
|
34 * resulting map is guaranteed to be sorted in the ascending key |
|
35 * order. |
|
36 * @throws MethodIsBlockingException if called from a callback because |
|
37 * the method needs all elements loaded and might block until |
|
38 * it's done |
|
39 */ |
|
40 SortedMap<Integer, ? extends JsVariable> toSparseArray() throws MethodIsBlockingException; |
|
41 } |