/**
  * 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;
 }
  // Get the list of all Twitter Search
  @GET
  @Produces(MediaType.APPLICATION_JSON)
  public String getListSearch(@Context HttpServletRequest req) throws NamingException {

    logger.debug("Method getListSearch(): Start");

    try {

      TwitterAnalysisLauncher launcher = new TwitterAnalysisLauncher();

      List<TwitterSearch> searchList = launcher.getTwitterSearchList(SearchTypeEnum.SEARCHAPI);

      JSONArray jsonArray = new JSONArray();

      for (TwitterSearch search : searchList) {

        jsonArray.put(search.toJSONObject());
      }

      // logger.debug("GET Result: " + jsonArray.toString());
      logger.debug("Method getListSearch(): End");
      return jsonArray.toString();
    } catch (Throwable th) {

      throw new SpagoBIRuntimeException(
          "Method getListSearch(): An error occurred in Twitter Historical Search API for REST service getListSearch ",
          th);
    }
  }
 /**
  * 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 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 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 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 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;
 }
 /**
  * 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 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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }
 /**
  * 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;
 }