Example #1
0
  public static Vector fromJsonArray(String jsonArray) {
    Vector vectorFacturas = new Vector();
    try {
      JSONArray array = new JSONArray(jsonArray);
      for (int i = 0; i < array.length(); i++) {
        JSONObject json = array.getJSONObject(i);
        Facturas fac = Facturas.fromJson(json.toString());

        vectorFacturas.addElement(fac);
      }
    } catch (JSONException e) {
      e.printStackTrace();
    }
    return vectorFacturas;
  }
  private void parseResultSet(Properties prop, ResultSet rs, List<JSONObject> newNotification)
      throws SQLException, JSONException {

    if (!rs.isBeforeFirst()) {
      log.debug("No Data Available ");
      return;
    } else {
      while (rs.next()) {
        JSONObject notiObj = new JSONObject();
        notiObj.put("title", rs.getString("tittle"));
        notiObj.put("auther", rs.getString("auther"));
        notiObj.put("publisher", rs.getString("publisher"));
        notiObj.put("release_date", rs.getDate("release_date").toString());
        notiObj.put("list_price", rs.getString("list_price"));
        notiObj.put("id", rs.getString("id"));
        newNotification.add(notiObj);
        invalidate_record(rs.getString("id"), prop);
        log.debug("==New Notification Record=" + notiObj.toString());
      }
    }
  }
  @Override
  public void parseBrowserResponse(
      HttpServletRequest httpRequest, ExecutorResponse executorResponse) {
    ShareAddressResponse response = (ShareAddressResponse) executorResponse;
    int status = response.getStatus();
    boolean isRGC = response.isRGC();
    String resultText = "N";
    if (status == ExecutorResponse.STATUS_OK) {
      resultText = "Y";
    }
    TxNode node = new TxNode();
    node.addMsg(resultText);
    if (isRGC) {
      Stop stop = response.getAddress();
      JSONObject stopJo = new JSONObject();
      try {
        stopJo.put("firstLine", stop.firstLine);
        stopJo.put("city", stop.city);
        stopJo.put("state", stop.state);
        stopJo.put("country", stop.country);
        stopJo.put("lon", stop.lon);
        stopJo.put("zip", stop.zip);
        stopJo.put("lat", stop.lat);
        stopJo.put("lon", stop.lon);
        stopJo.put("label", stop.label);
      } catch (JSONException e) {
        // TODO Auto-generated catch block
        logger.error("JSONException occured when we want to put a string into it");
        logger.error("cause:" + e.getCause() + ",message:" + e.getMessage());
      }

      node.addMsg(stopJo.toString());
    }
    httpRequest.setAttribute("node", node);

    // TODO save audio
  }