Lines Matching refs:index

34  * methods for accessing the values by index, and <code>put</code> methods for 
164 * Get the object value associated with an index.
165 * @param index
166 * The index must be between 0 and length() - 1.
168 * @throws JSONException If there is no value for the index.
170 public Object get(int index) throws JSONException {
171 Object o = opt(index);
173 throw new JSONException("JSONArray[" + index + "] not found.");
180 * Get the boolean value associated with an index.
183 * @param index The index must be between 0 and length() - 1.
185 * @throws JSONException If there is no value for the index or if the
188 public boolean getBoolean(int index) throws JSONException {
189 Object o = get(index);
199 throw new JSONException("JSONArray[" + index + "] is not a Boolean.");
204 * Get the double value associated with an index.
206 * @param index The index must be between 0 and length() - 1.
211 public double getDouble(int index) throws JSONException {
212 Object o = get(index);
217 throw new JSONException("JSONArray[" + index +
224 * Get the int value associated with an index.
226 * @param index The index must be between 0 and length() - 1.
232 public int getInt(int index) throws JSONException {
233 Object o = get(index);
235 ((Number)o).intValue() : (int)getDouble(index);
240 * Get the JSONArray associated with an index.
241 * @param index The index must be between 0 and length() - 1.
243 * @throws JSONException If there is no value for the index. or if the
246 public JSONArray getJSONArray(int index) throws JSONException {
247 Object o = get(index);
251 throw new JSONException("JSONArray[" + index +
257 * Get the JSONObject associated with an index.
258 * @param index subscript
260 * @throws JSONException If there is no value for the index or if the
263 public JSONObject getJSONObject(int index) throws JSONException {
264 Object o = get(index);
268 throw new JSONException("JSONArray[" + index +
274 * Get the long value associated with an index.
276 * @param index The index must be between 0 and length() - 1.
281 public long getLong(int index) throws JSONException {
282 Object o = get(index);
284 ((Number)o).longValue() : (long)getDouble(index);
289 * Get the string associated with an index.
290 * @param index The index must be between 0 and length() - 1.
292 * @throws JSONException If there is no value for the index.
294 public String getString(int index) throws JSONException {
295 return get(index).toString();
301 * @param index The index must be between 0 and length() - 1.
302 * @return true if the value at the index is null, or if there is no value.
304 public boolean isNull(int index) {
305 return JSONObject.NULL.equals(opt(index));
342 * Get the optional object value associated with an index.
343 * @param index The index must be between 0 and length() - 1.
345 * object at that index.
347 public Object opt(int index) {
348 return (index < 0 || index >= length()) ?
349 null : this.myArrayList.get(index);
354 * Get the optional boolean value associated with an index.
355 * It returns false if there is no value at that index,
358 * @param index The index must be between 0 and length() - 1.
361 public boolean optBoolean(int index) {
362 return optBoolean(index, false);
367 * Get the optional boolean value associated with an index.
368 * It returns the defaultValue if there is no value at that index or if
371 * @param index The index must be between 0 and length() - 1.
375 public boolean optBoolean(int index, boolean defaultValue) {
377 return getBoolean(index);
385 * Get the optional double value associated with an index.
386 * NaN is returned if there is no value for the index,
389 * @param index The index must be between 0 and length() - 1.
392 public double optDouble(int index) {
393 return optDouble(index, Double.NaN);
398 * Get the optional double value associated with an index.
399 * The defaultValue is returned if there is no value for the index,
402 * @param index subscript
406 public double optDouble(int index, double defaultValue) {
408 return getDouble(index);
416 * Get the optional int value associated with an index.
417 * Zero is returned if there is no value for the index,
420 * @param index The index must be between 0 and length() - 1.
423 public int optInt(int index) {
424 return optInt(index, 0);
429 * Get the optional int value associated with an index.
430 * The defaultValue is returned if there is no value for the index,
432 * @param index The index must be between 0 and length() - 1.
436 public int optInt(int index, int defaultValue) {
438 return getInt(index);
446 * Get the optional JSONArray associated with an index.
447 * @param index subscript
448 * @return A JSONArray value, or null if the index has no value,
451 public JSONArray optJSONArray(int index) {
452 Object o = opt(index);
458 * Get the optional JSONObject associated with an index.
459 * Null is returned if the key is not found, or null if the index has
462 * @param index The index must be between 0 and length() - 1.
465 public JSONObject optJSONObject(int index) {
466 Object o = opt(index);
472 * Get the optional long value associated with an index.
473 * Zero is returned if there is no value for the index,
476 * @param index The index must be between 0 and length() - 1.
479 public long optLong(int index) {
480 return optLong(index, 0);
485 * Get the optional long value associated with an index.
486 * The defaultValue is returned if there is no value for the index,
488 * @param index The index must be between 0 and length() - 1.
492 public long optLong(int index, long defaultValue) {
494 return getLong(index);
502 * Get the optional string value associated with an index. It returns an
503 * empty string if there is no value at that index. If the value
506 * @param index The index must be between 0 and length() - 1.
509 public String optString(int index) {
510 return optString(index, "");
515 * Get the optional string associated with an index.
518 * @param index The index must be between 0 and length() - 1.
522 public String optString(int index, String defaultValue) {
523 Object o = opt(index);
593 * Put or replace a boolean value in the JSONArray. If the index is greater
596 * @param index The subscript.
599 * @throws JSONException If the index is negative.
601 public JSONArray put(int index, boolean value) throws JSONException {
602 put(index, Boolean.valueOf(value));
608 * Put or replace a double value. If the index is greater than the length of
611 * @param index The subscript.
614 * @throws JSONException If the index is negative or if the value is
617 public JSONArray put(int index, double value) throws JSONException {
618 put(index, new Double(value));
624 * Put or replace an int value. If the index is greater than the length of
627 * @param index The subscript.
630 * @throws JSONException If the index is negative.
632 public JSONArray put(int index, int value) throws JSONException {
633 put(index, new Integer(value));
639 * Put or replace a long value. If the index is greater than the length of
642 * @param index The subscript.
645 * @throws JSONException If the index is negative.
647 public JSONArray put(int index, long value) throws JSONException {
648 put(index, new Long(value));
654 * Put or replace an object value in the JSONArray. If the index is greater
657 * @param index The subscript.
660 * @throws JSONException If the index is negative or if the the value is
663 public JSONArray put(int index, Object value) throws JSONException {
665 if (index < 0) {
666 throw new JSONException("JSONArray[" + index + "] not found.");
668 if (index < length()) {
669 this.myArrayList.set(index, value);
671 while (index != length()) {