List of usage examples for java.util HashMap toString
public String toString()
From source file:ru.apertum.qsystem.reports.formirovators.AuthorizedClientsPeriodUsers.java
@Override public String validate(String driverClassName, String url, String username, String password, HttpRequest request, HashMap<String, String> params) { // ? /*from www. ja va 2s . c o m*/ QLog.l().logger().trace("? \"" + params.toString() + "\"."); if (params.size() == 4) { // sd/ed/user_id/user Date sd, fd; String sdate, fdate, user; long user_id; try { //date = Uses.format_dd_MM_yyyy.parse(ss0[1]); sd = Uses.format_dd_MM_yyyy.parse(params.get("sd")); fd = Uses.format_dd_MM_yyyy.parse(params.get("ed")); sdate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(sd); fdate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(fd); user_id = Long.parseLong(params.get("user_id")); user = params.get("user"); } catch (ParseException | NumberFormatException ex) { return "<br> ! ? ? (..)."; } paramMap.put("sdate", sdate); paramMap.put("fdate", fdate); paramMap.put("sd", sd); paramMap.put("fd", fd); paramMap.put("user_id", user_id); paramMap.put("user", user); } else { return "<br> !"; } return null; }
From source file:ru.apertum.qsystem.reports.formirovators.AuthorizedClientsPeriodServices.java
@Override public String validate(String driverClassName, String url, String username, String password, HttpRequest request, HashMap<String, String> params) { // ? //from w w w. ja v a 2 s . c om QLog.l().logger().trace("? \"" + params.toString() + "\"."); if (params.size() == 4) { // sd/ed/user_id/user Date sd, fd; String sdate; String fdate; long user_id; String user; try { //date = Uses.format_dd_MM_yyyy.parse(ss0[1]); sd = Uses.format_dd_MM_yyyy.parse(params.get("sd")); fd = Uses.format_dd_MM_yyyy.parse(params.get("ed")); sdate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(sd); fdate = (new java.text.SimpleDateFormat("yyyy-MM-dd")).format(fd); user_id = Long.parseLong(params.get("user_id")); user = params.get("user"); } catch (ParseException | NumberFormatException ex) { return "<br> ! ? ? (..)."; } paramMap.put("sdate", sdate); paramMap.put("fdate", fdate); paramMap.put("sd", sd); paramMap.put("fd", fd); paramMap.put("user_id", user_id); paramMap.put("user", user); } else { return "<br> !"; } return null; }
From source file:com.inc.playground.playground.utils.NetworkUtilities.java
/** * * @param jsonObject//from w w w . j ava 2 s . c o m * @param currentLocation * @return * @throws JSONException */ public static EventsObject fillEventObject(JSONObject jsonObject, HashMap<String, Double> currentLocation) throws JSONException { String eventId = jsonObject.getString(Constants.EVENT_ID); EventsObject currentEvent = new EventsObject(); currentEvent.SetId(eventId); currentEvent.SetStatus(Constants.STATUS); currentEvent.SetName(jsonObject.getString(Constants.EVENT_NAME)); currentEvent.SetFormattedLocation(jsonObject.getString(Constants.EVENT_LOCATION)); currentEvent.SetType(jsonObject.getString(Constants.EVENT_TYPE)); currentEvent.SetSize(jsonObject.getString(Constants.EVENT_MIN_SIZE)); currentEvent.setMaxSize(jsonObject.getString(Constants.EVENT_MAX_SIZE)); currentEvent.SetDate(jsonObject.getString(Constants.EVENT_DATE)); currentEvent.SetStartTime(jsonObject.getString(Constants.START_TIME)); currentEvent.SetEndTime(jsonObject.getString(Constants.END_TIME)); currentEvent.SetDescription(jsonObject.getString(Constants.EVENT_DESCRIPTION)); currentEvent.SetCreatorId(jsonObject.getString(Constants.CREATED_BY)); currentEvent.setIsPublic(jsonObject.getString(Constants.IS_PUBLIC)); // find distance Log.d(TAG, currentLocation.toString()); double currentLon = currentLocation.get(Constants.LOCATION_LON); double currentLat = currentLocation.get(Constants.LOCATION_LAT); String eventLon = jsonObject.getJSONObject("location").getString(Constants.LOCATION_LON); String eventLat = jsonObject.getJSONObject("location").getString(Constants.LOCATION_LAT); currentEvent.SetPosition(eventLat, eventLon); currentEvent.SetDistance(Double.toString(calculateDistance(currentLon, currentLat, Double.parseDouble(eventLon), Double.parseDouble(eventLat))));//change order ArrayList<String> members = new ArrayList<>(); JSONArray membersJson = jsonObject.getJSONArray(Constants.EVENT_MEMBERS); for (int i = 0; i < membersJson.length(); i++) { members.add(membersJson.getString(i)); } currentEvent.SetMembers(members); ArrayList<String> approves = new ArrayList<>(); JSONArray approvesJson = jsonObject.getJSONArray(Constants.APPROVE_LIST); for (int i = 0; i < approvesJson.length(); i++) { approves.add(approvesJson.getString(i)); } currentEvent.setApproveList(approves); return currentEvent; }
From source file:widgets.Graphical_History.java
private void getlastvalue() { //TODO add something in the view //add last 5 values with their dates //featurePan2.addView(); JSONObject json_LastValues = null;/* w ww .j av a2s . c om*/ JSONArray itemArray = null; listeChoices = new ListView(context); ArrayList<HashMap<String, String>> listItem = new ArrayList<HashMap<String, String>>(); try { json_LastValues = Rest_com.connect(url + "stats/" + dev_id + "/" + state_key + "/last/5/", login, password); itemArray = json_LastValues.getJSONArray("stats"); for (int i = itemArray.length(); i >= 0; i--) { try { HashMap<String, String> map = new HashMap<String, String>(); map.put("value", itemArray.getJSONObject(i).getString("value")); map.put("date", itemArray.getJSONObject(i).getString("date")); listItem.add(map); Tracer.d(mytag, map.toString()); } catch (Exception e) { Tracer.e(mytag, "Error getting json value"); } } } catch (Exception e) { //return null; Tracer.e(mytag, "Error getting json object"); } SimpleAdapter adapter_feature = new SimpleAdapter(this.context, listItem, R.layout.item_phone, new String[] { "value", "date" }, new int[] { R.id.phone_value, R.id.phone_date }); listeChoices.setAdapter(adapter_feature); listeChoices.setScrollingCacheEnabled(false); }
From source file:gemlite.core.webapp.monitor.ServiceController.java
@RequestMapping(value = "/service/api", method = RequestMethod.GET) public void serviceapi(HttpServletResponse response) { //(service/*from ww w. j a v a2 s. c o m*/ try { monitor.services(); List<HashMap<String, Object>> rs = (List<HashMap<String, Object>>) (monitor .get(CommandMeta.LIST_SERVICES)); if (rs == null || rs.size() <= 0) return; //L< String[] arr = { "firstAt", "lastAt" }; for (HashMap<String, Object> data : rs) { for (String key : arr) { Long firstAt = 0L; try { firstAt = (Long) data.get(key); } catch (Exception e) { LogUtil.getCoreLog().error("firstAt is null:" + data.toString()); } String str1 = ""; if (firstAt != null && firstAt > 0) str1 = DateUtil.format(new Date(firstAt), DateUtil.yyyy_MM_dd_HHmmssSSS); data.put(key, str1); } } Collections.sort(rs, new Comparator<HashMap<String, Object>>() { @Override public int compare(HashMap<String, Object> o1, HashMap<String, Object> o2) { if (o1 == null || o1.get("serviceName") == null || o2 == null || o2.get("serviceName") == null) { LogUtil.getCoreLog().info("services has null value:{}{}", o1, o2); return 0; } return ((String) o1.get("serviceName")).compareTo((String) o2.get("serviceName")); } }); objectMapper.writeValue(response.getWriter(), rs); } catch (Exception e) { e.printStackTrace(); } }
From source file:ru.apertum.qsystem.reports.formirovators.ResponsesDateReport.java
@Override public String validate(String driverClassName, String url, String username, String password, HttpRequest request, HashMap<String, String> params) { // ? /*from w w w .j av a2 s . com*/ QLog.l().logger().trace("? \"" + params.toString() + "\"."); if (params.size() == 2) { Date sd; Date fd; Date fd1; try { sd = Uses.format_dd_MM_yyyy.parse(params.get("sd")); fd = Uses.format_dd_MM_yyyy.parse(params.get("ed")); fd1 = DateUtils.addDays(Uses.format_dd_MM_yyyy.parse(params.get("ed")), 1); } catch (ParseException ex) { return "<br> ! ? ? (..)."; } if (!sd.after(fd)) { paramMap.put("sd", sd); paramMap.put("ed", fd); paramMap.put("ed1", fd1); } else { return "<br> ! ?."; } } else { return "<br> !"; } return null;// ? }
From source file:org.ecocean.ApiAccess.java
public String checkRequest(Object obj, HttpServletRequest request, JSONObject jsonobj) { String err = null;/*from w ww . j a va 2 s .c o m*/ if (!request.getMethod().equals("POST") && !request.getMethod().equals("PUT")) return null; //we only care about PUT/POST for now HashMap<String, String> perm = permissions(obj, request); Iterator<?> keys = jsonobj.keys(); while (keys.hasNext()) { String key = (String) keys.next(); System.out.println(key); //we dont care what the value is, just if it is being set at all and shouldnt be if (perm.containsKey(key) && (perm.get(key) == null)) { err = "altering value for " + key + " disallowed by permissions: " + perm.toString(); break; } } return err; }
From source file:de.fhg.fokus.odp.middleware.unittest.xTestCKANGateway.java
/** * Test the getLatestDatasets method./*from w w w .j a v a 2 s.c om*/ */ @Test @SuppressWarnings({ "rawtypes", "unchecked" }) public void testGetLatestDatasets() { log.fine("########### GET LATEST DATASETS ###########"); // HashMap hm = CKANGatewayUtil.getLatestDatasetsOld(1); // System.out.println("test1 " + hm.toString()); HashMap hm = ckanGW.getLatestDatasets(1); log.fine(hm.toString()); Set<String> s = hm.keySet(); assertEquals(2, s.size()); // assertEquals(false, hm.toString().indexOf("bildung") != -1); // assertEquals(true, hm.toString().indexOf("arun_test") != -1); }
From source file:de.fhg.fokus.odp.middleware.unittest.xTestCKANGateway.java
/** * Test the getMostPopularDatasets method. * /*from www. j ava 2 s . c om*/ * NOTE: This test may fail if there are not enough rated datasets in the * registry. */ @Test @SuppressWarnings({ "unchecked", "rawtypes" }) public void testGetMostPopularDatasets() { log.fine("########### GET POPULAR DATASETS ###########"); HashMap hm = ckanGW.getMostPopularDatasets(10); log.fine(hm.toString()); Set<String> s = hm.keySet(); assertEquals(10, s.size()); // assertEquals(true, hm.toString().indexOf("rating=1.0") != -1); // assertEquals(false, hm.toString().indexOf("rating=-11.0") != -1); // assertEquals(true, hm.toString().indexOf("rating=-1.0") != -1); }
From source file:org.hfoss.posit.web.Communicator.java
/** * Get an image from the server using the guid as Key. * @param guid the Find's globally unique Id *//*from www.j av a 2 s. co m*/ public ArrayList<HashMap<String, String>> getRemoteFindImages(String guid) { ArrayList<HashMap<String, String>> imagesMap = null; // ArrayList<HashMap<String, String>> imagesMap = null; String imageUrl = server + "/api/getPicturesByFind?findId=" + guid + "&authKey=" + authKey; HashMap<String, String> sendMap = new HashMap<String, String>(); Log.i(TAG, "getRemoteFindImages, sendMap=" + sendMap.toString()); sendMap.put(PositDbHelper.FINDS_GUID, guid); addRemoteIdentificationInfo(sendMap); try { String imageResponseString = doHTTPPost(imageUrl, sendMap); Log.i(TAG, "getRemoteFindImages, response=" + imageResponseString); if (!imageResponseString.equals(RESULT_FAIL)) { JSONArray jsonArr = new JSONArray(imageResponseString); imagesMap = new ArrayList<HashMap<String, String>>(); // imagesMap = new ArrayList<HashMap<String, String>>(); for (int i = 0; i < jsonArr.length(); i++) { JSONObject jsonObj = jsonArr.getJSONObject(i); if (Utils.debug) Log.i(TAG, "JSON Image Response String: " + jsonObj.toString()); // imagesMap.add((HashMap<String, String>) jsonArr.get(i)); Iterator<String> iterKeys = jsonObj.keys(); HashMap<String, String> map = new HashMap<String, String>(); while (iterKeys.hasNext()) { String key = iterKeys.next(); map.put(key, jsonObj.getString(key)); } imagesMap.add(map); } } } catch (Exception e) { Log.i(TAG, e.getMessage()); e.printStackTrace(); } if (imagesMap != null && Utils.debug) Log.i(TAG, "getRemoteFindImages, imagesMap=" + imagesMap.toString()); else Log.i(TAG, "getRemoteFindImages, imagesMap= null"); return imagesMap; }