/** * Get the object value associated with an index. * @param index must be between 0 and length() - 1 * @return An object value. * @throws JSONException If there is no value for the index. */ private Object get(int index) { Object object = opt(index); if (object == null) { throw new RuntimeException("JSONArray[" + index + "] not found."); } return object; }
/** * Determine if the value is null. * @param index must be between 0 and length() - 1 * @return true if the value at the index is null, or if there is no value. */ public boolean isNull(int index) { return JSONObject.NULL.equals(this.opt(index)); }
/** * Determine if the value is null. * @webref * @param index must be between 0 and length() - 1 * @return true if the value at the index is null, or if there is no value. */ public boolean isNull(int index) { return JSONObject.NULL.equals(this.opt(index)); }
/** * Get the object value associated with an index. * @param index must be between 0 and length() - 1 * @return An object value. * @throws RuntimeException If there is no value for the index. */ public Object get(int index) { Object object = opt(index); if (object == null) { throw new RuntimeException("JSONArray[" + index + "] not found."); } return object; }
/** * Get the optional string associated with an index. * The defaultValue is returned if the key is not found. * * @param index The index must be between 0 and length() - 1. * @param defaultValue The default value. * @return A String value. */ public String getString(int index, String defaultValue) { Object object = this.opt(index); return JSONObject.NULL.equals(object) ? defaultValue : object.toString(); }
/** * Remove an index and close the hole. * * @webref jsonarray:method * @brief Removes an element * @param index the index value of the element to be removed * @return The value that was associated with the index, or null if there was no value. * @see JSONArray#size() * @see JSONArray#append(String) */ public Object remove(int index) { Object o = this.opt(index); this.myArrayList.remove(index); return o; }
/** * Get the optional string associated with an index. * The defaultValue is returned if the key is not found. * * @param index The index must be between 0 and length() - 1. * @param defaultValue The default value. * @return A String value. */ public String getString(int index, String defaultValue) { Object object = this.opt(index); return JSONObject.NULL.equals(object) ? defaultValue : object.toString(); }
/** * Remove an index and close the hole. * * @webref jsonarray:method * @brief Removes an element * @param index the index value of the element to be removed * @return The value that was associated with the index, or null if there was no value. * @see JSONArray#size() * @see JSONArray#append(String) */ public Object remove(int index) { Object o = this.opt(index); this.myArrayList.remove(index); return o; }