/**
  * Put or replace an object value in the JSONArray. If the index is greater than the length of the
  * JSONArray, then null elements will be added as necessary to pad it out.
  *
  * @param index The subscript.
  * @param value The value to put into the array. The value should be a Boolean, Double, Integer,
  *     JSONArray, JSONObject, Long, or String, or the JSONObject.NULL object.
  * @return this.
  * @throws JSONException If the index is negative or if the the value is an invalid number.
  */
 public JSONArray put(int index, Object value) throws JSONException {
   JSONObject.testValidity(value);
   if (index < 0) {
     throw new JSONException("JSONArray[" + index + "] not found.");
   }
   if (index < length()) {
     this.myArrayList.set(index, value);
   } else {
     while (index != length()) {
       put(JSONObject.NULL);
     }
     put(value);
   }
   return this;
 }
 /**
  * Put a value in the JSONArray, where the value will be a JSONObject which is produced from a
  * Map.
  *
  * @param index The subscript.
  * @param value The Map value.
  * @return this.
  * @throws JSONException If the index is negative or if the the value is an invalid number.
  */
 public JSONArray put(int index, Map value) throws JSONException {
   put(index, new JSONObject(value));
   return this;
 }
 /**
  * Put or replace an int value. If the index is greater than the length of the JSONArray, then
  * null elements will be added as necessary to pad it out.
  *
  * @param index The subscript.
  * @param value An int value.
  * @return this.
  * @throws JSONException If the index is negative.
  */
 public JSONArray put(int index, int value) throws JSONException {
   put(index, new Integer(value));
   return this;
 }
 /**
  * Put or replace a long value. If the index is greater than the length of the JSONArray, then
  * null elements will be added as necessary to pad it out.
  *
  * @param index The subscript.
  * @param value A long value.
  * @return this.
  * @throws JSONException If the index is negative.
  */
 public JSONArray put(int index, long value) throws JSONException {
   put(index, new Long(value));
   return this;
 }
 /**
  * Put a value in the JSONArray, where the value will be a JSONArray which is produced from a
  * Collection.
  *
  * @param index The subscript.
  * @param value A Collection value.
  * @return this.
  * @throws JSONException If the index is negative or if the value is not finite.
  */
 public JSONArray put(int index, Collection value) throws JSONException {
   put(index, new JSONArray(value));
   return this;
 }
 /**
  * Put or replace a double value. If the index is greater than the length of the JSONArray, then
  * null elements will be added as necessary to pad it out.
  *
  * @param index The subscript.
  * @param value A double value.
  * @return this.
  * @throws JSONException If the index is negative or if the value is not finite.
  */
 public JSONArray put(int index, double value) throws JSONException {
   put(index, new Double(value));
   return this;
 }
 /**
  * Put a value in the JSONArray, where the value will be a JSONObject which is produced from a
  * Map.
  *
  * @param value A Map value.
  * @return this.
  */
 public JSONArray put(Map value) {
   put(new JSONObject(value));
   return this;
 }
 /**
  * Put or replace a boolean value in the JSONArray. If the index is greater than the length of the
  * JSONArray, then null elements will be added as necessary to pad it out.
  *
  * @param index The subscript.
  * @param value A boolean value.
  * @return this.
  * @throws JSONException If the index is negative.
  */
 public JSONArray put(int index, boolean value) throws JSONException {
   put(index, value ? Boolean.TRUE : Boolean.FALSE);
   return this;
 }
 /**
  * Append an long value. This increases the array's length by one.
  *
  * @param value A long value.
  * @return this.
  */
 public JSONArray put(long value) {
   put(new Long(value));
   return this;
 }
Exemplo n.º 10
0
 /**
  * Append an int value. This increases the array's length by one.
  *
  * @param value An int value.
  * @return this.
  */
 public JSONArray put(int value) {
   put(new Integer(value));
   return this;
 }
Exemplo n.º 11
0
 /**
  * Append a double value. This increases the array's length by one.
  *
  * @param value A double value.
  * @throws JSONException if the value is not finite.
  * @return this.
  */
 public JSONArray put(double value) throws JSONException {
   Double d = new Double(value);
   JSONObject.testValidity(d);
   put(d);
   return this;
 }
Exemplo n.º 12
0
 /**
  * Put a value in the JSONArray, where the value will be a JSONArray which is produced from a
  * Collection.
  *
  * @param value A Collection value.
  * @return this.
  */
 public JSONArray put(Collection value) {
   put(new JSONArray(value));
   return this;
 }
Exemplo n.º 13
0
 /**
  * Append a boolean value. This increases the array's length by one.
  *
  * @param value A boolean value.
  * @return this.
  */
 public JSONArray put(boolean value) {
   put(value ? Boolean.TRUE : Boolean.FALSE);
   return this;
 }