List of usage examples for java.util Map toString
public String toString()
From source file:com.opensoc.parsing.test.BasicLancopeParserTest.java
/** * Test method for {@link com.opensoc.parsing.parsers.BasicLancopeParser#parse(byte[])}. * @throws Exception //from www .j a va 2 s .co m * @throws IOException */ public void testParse() throws IOException, Exception { for (String inputString : getInputStrings()) { JSONObject parsed = parser.parse(inputString.getBytes()); assertNotNull(parsed); System.out.println(parsed); JSONParser parser = new JSONParser(); Map<?, ?> json = null; try { json = (Map<?, ?>) parser.parse(parsed.toJSONString()); assertEquals(true, validateJsonData(super.getSchemaJsonString(), json.toString())); } catch (ParseException e) { e.printStackTrace(); } } }
From source file:org.nuxeo.directory.connector.json.akeneo.AkeneoInMemoryConnector.java
@Override public List<String> queryEntryIds(Map<String, Serializable> filter, Set<String> fulltext) { List<String> ids = new ArrayList<String>(); String valueToFind = ""; log.info("filter " + filter.toString()); if (filter.containsKey("label")) { valueToFind = (String) filter.get("label"); log.info("valueToFind [" + valueToFind + "]"); if (valueToFind != null) { valueToFind = valueToFind.toLowerCase(); }/*from w w w .ja v a2 s . com*/ } log.info("mapping [" + mapping.get("label") + "]"); String fieldName = mapping.get("label"); // do the search data_loop: for (String id : getEntryIds()) { Map<String, Object> map = getEntryMap(id); Object value = map.get(fieldName); if (value == null) { continue data_loop; } if (value.toString().toLowerCase().indexOf(valueToFind) < 0) { continue data_loop; } ids.add(id); } log.info("ids size [" + ids.size() + "]"); log.info("ids [" + ids.toString() + "]"); return ids; }
From source file:edu.uiowa.icts.util.SummarizeListTest.java
public void testDescendingOrder(Map<String, Integer> m) { String a = m.toString(); int prev = 500; while (a.indexOf('=') != -1) { a = a.substring(a.indexOf('=') + 1); assertTrue(prev > a.charAt(0)); prev = a.charAt(0);/*from w ww .ja v a2 s .c o m*/ } }
From source file:com.opensoc.parsing.test.BasicIseParserTest.java
/** * Test method for// w w w . ja v a2s . co m * {@link com.opensoc.parsing.parsers.BasicIseParser#parse(byte[])}. * * @throws IOException * @throws Exception */ public void testParse() throws ParseException, IOException, Exception { for (String inputString : getInputStrings()) { JSONObject parsed = parser.parse(inputString.getBytes()); assertNotNull(parsed); System.out.println(parsed); JSONParser parser = new JSONParser(); Map<?, ?> json = null; try { json = (Map<?, ?>) parser.parse(parsed.toJSONString()); assertEquals(true, validateJsonData(super.getSchemaJsonString(), json.toString())); } catch (ParseException e) { e.printStackTrace(); } } }
From source file:com.yahoo.pulsar.zookeeper.ZkBookieRackAffinityMapping.java
@Override public void onUpdate(String path, Map<String, Map<BookieSocketAddress, BookieInfo>> data, Stat stat) { if (rackawarePolicy != null) { LOG.info("Bookie rack info updated to {}. Notifying rackaware policy.", data.toString()); List<BookieSocketAddress> bookieAddressList = new ArrayList<>(); for (Map<BookieSocketAddress, BookieInfo> bookieMapping : data.values()) { bookieAddressList.addAll(bookieMapping.keySet()); }/*from ww w.j av a2 s . c om*/ rackawarePolicy.onBookieRackChange(bookieAddressList); } }
From source file:com.phearom.um.model.RemoteJSONSource.java
private JSONObject sendPost(String urlString) throws Exception { URL url = new URL(urlString); HttpURLConnection con = (HttpURLConnection) url.openConnection(); //add reuqest header con.setRequestMethod("POST"); con.setRequestProperty("User-Agent", "Mozilla/5.0"); con.setRequestProperty("Accept-Language", "en-US,en;q=0.5"); Map<String, String> params = new HashMap<>(); params.put("limit", "25"); params.put("offset", "0"); String parameter = params.toString().replace(",", "&"); // Send post request con.setDoOutput(true);// w w w .j a v a 2 s. c o m DataOutputStream wr = new DataOutputStream(con.getOutputStream()); wr.writeBytes(parameter); wr.flush(); wr.close(); BufferedReader in = new BufferedReader(new InputStreamReader(con.getInputStream())); String inputLine; StringBuffer response = new StringBuffer(); while ((inputLine = in.readLine()) != null) { response.append(inputLine); } in.close(); return new JSONObject(response.toString()); }
From source file:com.huofu.RestaurantOS.manager.ApisManager.java
/** * ???/*w w w . j a v a 2s . c om*/ * @param orderId ?id * @param repast_date * @param time_bucket_id id * @param packaged ? * @param store_meal_checkouts ?? * @param checkout_type ??01 * @param port_id ?id * @param callback */ public static void mealCheckout(String content, Handler handler, String orderId, String repast_date, long time_bucket_id, int packaged, JSONArray store_meal_checkouts, int checkout_type, long port_id, ApiCallback callback) { com.alibaba.fastjson.JSONArray array = new com.alibaba.fastjson.JSONArray(); try { if (store_meal_checkouts != null) { for (int k = 0; k < store_meal_checkouts.length(); k++) { org.json.JSONObject obj = (org.json.JSONObject) store_meal_checkouts.get(k); JSONObject oj = new JSONObject(); oj.put("amount", obj.get("amount")); oj.put("charge_item_id", obj.get("charge_item_id")); oj.put("packaged", obj.get("packaged")); oj.put("orderId", orderId); array.add(oj); } } } catch (Exception e) { } Map map = new HashMap(); map.put("order_id", orderId); map.put("repast_date", repast_date); map.put("time_bucket_id", time_bucket_id); map.put("packaged", packaged); map.put("store_meal_checkouts", array);//store_meal_checkouts); map.put("checkout_type", checkout_type); map.put("port_id", port_id); CommonUtils.LogWuwei(PushMealActivity.tag, "??:" + map.toString()); new SetPortMealCheckout(store_meal_checkouts, content, handler).requestWithParams(map, callback); }
From source file:net.itransformers.topologyviewer.fulfilmentfactory.impl.TestFulfilmentImpl.java
private void sendCommand(String line, Set<String> vars, Map<String, String> parameters) { for (String var : vars) { if (!parameters.containsKey(var)) { throw new RuntimeException(String.format( "Can not find variable with name '%s' in parameters map %s", var, parameters.toString())); }/*from ww w .java2s.c o m*/ line = line.replaceAll("\\$" + var, parameters.get(var)); } cli.sendData(line); }
From source file:com.jxt.web.controller.CommandController.java
@RequestMapping(value = "/threadDump", method = RequestMethod.GET) public ModelAndView echo(@RequestParam("application") String applicationName, @RequestParam("agent") String agentId, @RequestParam("startTimeStamp") long startTimeStamp) throws TException { AgentInfo agentInfo = agentService.getAgentInfo(applicationName, agentId, startTimeStamp); if (agentInfo == null) { return createResponse(false, String.format("Can't find suitable PinpointServer(%s/%s/%d).", applicationName, agentId, startTimeStamp)); }/*from w w w .j ava 2s. c om*/ TCommandThreadDump threadDump = new TCommandThreadDump(); try { PinpointRouteResponse pinpointRouteResponse = agentService.invoke(agentInfo, threadDump); if (pinpointRouteResponse != null && pinpointRouteResponse.getRouteResult() == TRouteResult.OK) { TBase<?, ?> result = pinpointRouteResponse.getResponse(); if (result == null) { return createResponse(false, "result null."); } else if (result instanceof TCommandThreadDumpResponse) { Map<String, String> map = createThreadDump((TCommandThreadDumpResponse) result); logger.debug("{}", map.toString()); return createResponse(true, map); } else if (result instanceof TResult) { return createResponse(false, ((TResult) result).getMessage()); } else { return createResponse(false, result.toString()); } } else { return createResponse(false, "unknown"); } } catch (TException e) { return createResponse(false, e.getMessage()); } }
From source file:com.alibaba.jstorm.daemon.nimbus.metric.uploader.AlimonitorClient.java
private boolean sendRequest(int collection_flag, String error_message, Map<String, Object> msg) throws Exception { boolean ret = false; if (msg.size() == 0) return ret; Map jsonObj = buildAliMonitorMsg(collection_flag, error_message); addMsgData(jsonObj, msg);/*from w w w .j a v a 2s .c o m*/ String jsonMsg = jsonObj.toString(); LOG.info(jsonMsg); if (post) { String url = buildURL(); ret = httpPost(url, jsonMsg); } else { String request = buildRqstAddr(); StringBuilder postAddr = new StringBuilder(); postAddr.append(request); postAddr.append(URLEncoder.encode(jsonMsg)); ret = httpGet(postAddr); } return ret; }