@SuppressWarnings("unchecked")
  private String searchAndReturnDatainJSONFormat(
      String sLong, String sLat, String radius, String result) {
    String query = "";
    String retValue = "";
    PersistenceManager pm = PMF.get().getPersistenceManager();

    StringBuffer sb = new StringBuffer(100);
    sb.append("http://ws.geonames.net/findNearbyPostalCodesJSON?lat=");
    sb.append(sLat);
    sb.append("&lng=");
    sb.append(sLong);
    sb.append("&radius=");
    sb.append(radius);
    sb.append("&maxRows=100");
    sb.append("&username="******"URL:" + sb);
    String JSONResult = callServletToGetData(url);
    String zipCodeArray[] = null;

    Integer iResult = new Integer(result);

    String state = parseJSONDatatoGetState(JSONResult);
    zipCodeArray = parseJSONData(JSONResult);
    ArrayList beanList = new ArrayList();
    HashMap containsMap = new HashMap();
    List<EPAToxicDataBean> xmlDataList = null;
    try {
      if (zipCodeArray != null) {
        int resultCounter = 0;
        System.out.println("Startime" + new Date());
        for (String zipCode : zipCodeArray) {

          if (resultCounter >= iResult) {
            break;
          }
          query = "LocationZIPCode =='" + zipCode + "'";
          System.out.println("Executing Query:" + query);
          xmlDataList =
              (List<EPAToxicDataBean>) pm.newQuery(EPAToxicDataBean.class, query).execute();

          if (xmlDataList != null) {

            for (EPAToxicDataBean rec : xmlDataList) {
              if (resultCounter < iResult) {
                if (!containsMap.containsKey(rec.getFacilityregistryId())) {
                  beanList.add(rec);
                  containsMap.put(rec.getFacilityregistryId(), 0);
                  ++resultCounter;
                  System.out.println("ResultSize time:" + beanList.size());
                } else {
                  continue;
                }
              } else {
                break;
              }
            }
          }
        }
      }
      if (beanList.size() > 0) {
        retValue = new JSONSerializer().include("*").serialize("EPAData", beanList);
      }
    } catch (Exception exec) {
      System.out.println("Error" + exec.getMessage());
      System.out.println("Error at time" + new Date());
    } finally {
      JsonReturnValueForIphone = new JSONSerializer().include("*").serialize("EPAData", beanList);
    }
    return retValue;
  }
  @SuppressWarnings("unchecked")
  private String searchAndReturnDatainJSONFormatForWebApp(
      String sLong, String sLat, String radius, String result) {
    String query = "";
    String retValue = "";
    PersistenceManager pm = PMF.get().getPersistenceManager();

    StringBuffer sb = new StringBuffer(100);
    sb.append("http://ws.geonames.net/findNearbyPostalCodesJSON?lat=");
    sb.append(sLat);
    sb.append("&lng=");
    sb.append(sLong);
    sb.append("&radius=");
    sb.append(radius);
    sb.append("&maxRows=100");
    sb.append("&username="******"URL:" + sb);
    String JSONResult = callServletToGetData(url);
    String zipCodeArray[] = null;

    Integer iResult = new Integer(result);

    String state = parseJSONDatatoGetState(JSONResult);
    zipCodeArray = parseJSONData(JSONResult);
    ArrayList beanList = new ArrayList();
    List<EPAToxicDataBean> xmlDataList = null;

    try {
      if (zipCodeArray != null) {
        int resultCounter = 0;
        System.out.println("Startime" + new Date());
        HashMap containsMap = new HashMap();
        for (String zipCode : zipCodeArray) {

          if (resultCounter >= iResult) {
            break;
          }
          query =
              "SELECT FROM  com.mycompany.sampleProject.server.EPAToxicDataBean "
                  + "where LocationZIPCode.startsWith(tradeName) "
                  + "parameters String tradeName";
          System.out.println("Executing Query:" + query);
          xmlDataList = (List<EPAToxicDataBean>) pm.newQuery(query).execute(zipCode);

          if (xmlDataList != null) {

            for (EPAToxicDataBean rec : xmlDataList) {
              if (resultCounter < iResult) {
                if (!containsMap.containsKey(rec.getFacilityregistryId())) {
                  beanList.add(rec);
                  ++resultCounter;
                  containsMap.put(rec.getFacilityregistryId(), 0);
                  System.out.println("ResultSize time:" + beanList.size());
                } else {
                  continue;
                }

              } else {
                break;
              }
            }
          }
        }
      }
      if (beanList.size() > 0) {

        StringBuffer retValuBuffer = new StringBuffer(8000);
        retValuBuffer.append("[");
        int beanCounter = 0;
        for (int i = 0; i < beanList.size(); ++i) {
          org.json.JSONObject jsonObject = new org.json.JSONObject(beanList.get(i));
          retValuBuffer.append(jsonObject.toString());
          if ((beanCounter != beanList.size() - 1) && beanList.size() > 1) {
            retValuBuffer.append(",");
          }
          ++beanCounter;
        }
        retValuBuffer.append("]");

        retValue = retValuBuffer.toString();
      }
    } catch (Exception exec) {
      System.out.println("Error" + exec.getMessage());
      System.out.println("Error at time" + new Date());
    } finally {
      StringBuffer retValuBuffer = new StringBuffer(8000);
      retValuBuffer.append("[");
      int beanCounter = 0;
      for (int i = 0; i < beanList.size(); ++i) {
        org.json.JSONObject jsonObject = new org.json.JSONObject(beanList.get(i));
        retValuBuffer.append(jsonObject.toString());
        if ((beanCounter != beanList.size() - 1) && beanList.size() > 1) {
          retValuBuffer.append(",");
        }
        ++beanCounter;
      }
      retValuBuffer.append("]");
      JsonReturnValueForIphone = retValuBuffer.toString();
    }
    return retValue;
  }