List of usage examples for java.util Map toString
public String toString()
From source file:com.apptentive.android.sdk.Apptentive.java
/** * <p>Allows you to pass arbitrary string data to the server along with this person's info. This method will replace all * custom person data that you have set for this app. Calls to this method are idempotent.</p> * <p>To add a single piece of custom person data, use {@link #addCustomPersonData}</p> * <p>To remove a single piece of custom person data, use {@link #removeCustomPersonData}</p> * * @param context The context from which this method is called. * @param customPersonData A Map of key/value pairs to send to the server. *//*w ww .j a v a 2s. c o m*/ public static void setCustomPersonData(Context context, Map<String, String> customPersonData) { Log.w("Setting custom person data: %s", customPersonData.toString()); try { CustomData customData = new CustomData(); for (String key : customPersonData.keySet()) { customData.put(key, customPersonData.get(key)); } PersonManager.storeCustomPersonData(context, customData); } catch (JSONException e) { Log.e("Unable to set custom person data.", e); } }
From source file:jahirfiquitiva.iconshowcase.utilities.utils.NotificationUtils.java
public static void sendFirebaseNotification(Context context, Class mainActivity, Map<String, String> data, String title, String content) { Preferences mPrefs = new Preferences(context); if (!(mPrefs.getNotifsEnabled())) return;/* w w w .ja v a2s. c o m*/ int ledColor = ThemeUtils.darkOrLight(context, R.color.dark_theme_accent, R.color.light_theme_accent); NotificationCompat.Builder notificationBuilder = new NotificationCompat.Builder(context) .setSmallIcon(R.drawable.ic_notifications).setContentTitle(title).setTicker(title) .setContentText(content).setAutoCancel(true).setOngoing(false).setColor(ledColor); Intent intent = new Intent(); int flag = 0; if (mPrefs.getLauncherIconShown()) { intent = new Intent(context, mainActivity); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); if (data != null) { if (data.size() > 0) { for (int i = 0; i < data.size(); i++) { String[] dataValue = data.toString().replace("{", "").replace("}", "").split(",")[i] .split("="); Timber.d("Key: " + dataValue[0] + " - Value: " + dataValue[1]); intent.putExtra(dataValue[0], dataValue[1]); } } } flag = PendingIntent.FLAG_ONE_SHOT; } PendingIntent pendingIntent = PendingIntent.getActivity(context, 0 /* Request code */, intent, flag); notificationBuilder.setContentIntent(pendingIntent); Uri ringtoneUri = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Resources resources = context.getResources(), systemResources = Resources.getSystem(); notificationBuilder.setSound(mPrefs.getNotifsSoundEnabled() ? ringtoneUri : null); notificationBuilder.setVibrate(mPrefs.getNotifsVibrationEnabled() ? new long[] { 500, 500 } : null); NotificationManager notificationManager = (NotificationManager) context .getSystemService(Context.NOTIFICATION_SERVICE); Notification notification = notificationBuilder.build(); if (mPrefs.getNotifsEnabled()) { notification.flags |= Notification.FLAG_SHOW_LIGHTS; notification.ledARGB = ledColor; notification.ledOnMS = resources.getInteger( systemResources.getIdentifier("config_defaultNotificationLedOn", "integer", "android")); notification.ledOffMS = resources.getInteger( systemResources.getIdentifier("config_defaultNotificationLedOff", "integer", "android")); } else { notification.ledOnMS = 0; notification.ledOffMS = 0; } notificationManager.notify(1 /* ID of notification */, notificationBuilder.build()); }
From source file:com.yanzhenjie.andserver.sample.response.RequestLoginHandler.java
@Override public void handle(HttpRequest request, HttpResponse response, HttpContext context) throws HttpException, IOException { Map<String, String> params = HttpRequestParser.parse(request); Log.i("AndServer", "Params: " + params.toString()); String userName = params.get("username"); String password = params.get("password"); if ("123".equals(userName) && "123".equals(password)) { StringEntity stringEntity = new StringEntity("Login Succeed", "utf-8"); response.setEntity(stringEntity); } else {// w ww .jav a 2 s. co m StringEntity stringEntity = new StringEntity("Login Failed", "utf-8"); response.setEntity(stringEntity); } }
From source file:com.seer.datacruncher.utils.validation.CodiceFiscaleAttributes.java
public String toString() { String myInternals = ""; try {//www . ja v a2 s.co m Map internals = BeanUtils.describe(this); myInternals = internals.toString(); } catch (Exception e) { e.printStackTrace(); } return myInternals; }
From source file:org.apache.storm.kafka.ZkState.java
public void writeJSON(String path, Map<Object, Object> data) { LOG.debug("Writing {} the data {}", path, data.toString()); writeBytes(path, JSONValue.toJSONString(data).getBytes(Charset.forName("UTF-8"))); }
From source file:com.anhth12.spark.kafka.consumer.ZkState.java
public void writeJSON(String path, Map<Object, Object> data) { log.info("Writing " + path + " the data " + data.toString()); writeBytes(path, JSONValue.toJSONString(data).getBytes(Charset.forName("UTF-8"))); }
From source file:org.dojotoolkit.zazl.internal.XMLHttpRequestUtils.java
@SuppressWarnings({ "unchecked", "rawtypes" }) public static String xhrRequest(String shrDataString) { InputStream is = null;/*w w w . ja v a 2 s. co m*/ String json = null; try { logger.logp(Level.FINER, XMLHttpRequestUtils.class.getName(), "xhrRequest", "shrDataString [" + shrDataString + "]"); Map<String, Object> xhrData = (Map<String, Object>) JSONParser.parse(new StringReader(shrDataString)); String url = (String) xhrData.get("url"); String method = (String) xhrData.get("method"); List headers = (List) xhrData.get("headers"); URL requestURL = createURL(url); URI uri = new URI(requestURL.toString()); HashMap httpMethods = new HashMap(7); httpMethods.put("DELETE", new HttpDelete(uri)); httpMethods.put("GET", new HttpGet(uri)); httpMethods.put("HEAD", new HttpHead(uri)); httpMethods.put("OPTIONS", new HttpOptions(uri)); httpMethods.put("POST", new HttpPost(uri)); httpMethods.put("PUT", new HttpPut(uri)); httpMethods.put("TRACE", new HttpTrace(uri)); HttpUriRequest request = (HttpUriRequest) httpMethods.get(method.toUpperCase()); if (request.equals(null)) { throw new Error("SYNTAX_ERR"); } for (Object header : headers) { StringTokenizer st = new StringTokenizer((String) header, ":"); String name = st.nextToken(); String value = st.nextToken(); request.addHeader(name, value); } HttpClient client = new DefaultHttpClient(); HttpResponse response = client.execute(request); Map headerMap = new HashMap(); HeaderIterator headerIter = response.headerIterator(); while (headerIter.hasNext()) { Header header = headerIter.nextHeader(); headerMap.put(header.getName(), header.getValue()); } int status = response.getStatusLine().getStatusCode(); String statusText = response.getStatusLine().toString(); is = response.getEntity().getContent(); BufferedReader br = new BufferedReader(new InputStreamReader(is)); String line = null; StringBuffer sb = new StringBuffer(); while ((line = br.readLine()) != null) { sb.append(line); sb.append('\n'); } Map m = new HashMap(); m.put("status", new Integer(status)); m.put("statusText", statusText); m.put("responseText", sb.toString()); m.put("headers", headerMap.toString()); StringWriter w = new StringWriter(); JSONSerializer.serialize(w, m); json = w.toString(); logger.logp(Level.FINER, XMLHttpRequestUtils.class.getName(), "xhrRequest", "json [" + json + "]"); } catch (Throwable e) { logger.logp(Level.SEVERE, XMLHttpRequestUtils.class.getName(), "xhrRequest", "Failed request for [" + shrDataString + "]", e); } finally { if (is != null) { try { is.close(); } catch (IOException e) { } } } return json; }
From source file:ch.uzh.ddis.thesis.lambda_architecture.speed.spout.kafka.ZkState.java
public void writeJSON(String path, Map<Object, Object> data) { LOG.debug("Writing " + path + " the data " + data.toString()); writeBytes(path, JSONValue.toJSONString(data).getBytes(Charset.forName("UTF-8"))); }
From source file:edu.harvard.i2b2.oauth2.register.ejb.UserManager.java
public String printSession() { FacesContext context = FacesContext.getCurrentInstance(); Map<String, Object> s = context.getExternalContext().getSessionMap(); return s.toString(); }
From source file:com.amazon.notification.controllers.NotificationController.java
@RequestMapping(value = "/data", produces = "application/json", method = RequestMethod.GET) @ResponseBody/*from ww w . j a va 2s . com*/ public String getData(@RequestParam String query) { Map<String, String> map = DataManager.getInstance().getDataMap().hgetAll(query); String output = ""; if (map != null) { output = map.toString(); } return output; }