List of usage examples for java.lang Object toString
public String toString()
From source file:Main.java
public static void dumpBatteryStats(Context context) { IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED); Intent batteryStatus = context.registerReceiver(null, ifilter); Bundle bundle = batteryStatus.getExtras(); for (String key : bundle.keySet()) { Object value = bundle.get(key); Log.d(TAG, String.format("Battery,%s=%s (%s)", key, value.toString(), value.getClass().getName())); }//w w w. ja v a2 s .c o m }
From source file:Main.java
public static boolean getBooleanValue(Object o, boolean defaultVal) { if (o == null) return Boolean.valueOf(defaultVal); if (o.toString().trim().length() == 0) return Boolean.valueOf(defaultVal); if (o instanceof Boolean) return (Boolean) o; if (o instanceof String) return Boolean.parseBoolean((String) o); return Boolean.valueOf(defaultVal); }
From source file:com.surfs.storage.web.utils.WebUtils.java
public static String getCrrentDataCenterName(HttpSession session) { /*return "uspod1/uscluster2";*/ Object dataCenterName = session.getAttribute("dataCenterName"); return dataCenterName != null ? dataCenterName.toString() : null; }
From source file:com.commonsware.android.gcm.cmd.GCM.java
private static void sendMessage(String apiKey, List<String> devices, Properties data) throws Exception { Sender sender = new Sender(apiKey); Message.Builder builder = new Message.Builder(); for (Object o : data.keySet()) { String key = o.toString(); builder.addData(key, data.getProperty(key)); }//from ww w . j av a 2 s.c o m MulticastResult mcResult = sender.send(builder.build(), devices, 5); for (int i = 0; i < mcResult.getTotal(); i++) { Result result = mcResult.getResults().get(i); if (result.getMessageId() != null) { String canonicalRegId = result.getCanonicalRegistrationId(); if (canonicalRegId != null) { System.err.println(String.format("%s canonical ID = %s", devices.get(i), canonicalRegId)); } else { System.out.println(String.format("%s success", devices.get(i))); } } else { String error = result.getErrorCodeName(); if (Constants.ERROR_NOT_REGISTERED.equals(error)) { System.err.println(String.format("%s is unregistered", devices.get(i))); } else if (error != null) { System.err.println(String.format("%s error = %s", devices.get(i), error)); } } } }
From source file:Main.java
public static String isNull_String(Object response) { if (response == null | response.equals(null)) return ""; else/*from ww w . jav a 2 s. c o m*/ return response.toString().trim(); }
From source file:org.n52.restfulwpsproxy.serializer.json.AbstractWPSJsonModule.java
protected static final String toStringOrEmpty(Object object) { return object == null ? "" : object.toString(); }
From source file:net.kamhon.ieagle.util.StringUtil.java
public static String convertToStringWithSeparator(List<?> list, String separator, boolean withSpacing) { String result = ""; if (CollectionUtil.isEmpty(list)) { return ""; }// w w w .j a va 2 s.c o m for (Iterator<?> iterator = list.iterator(); iterator.hasNext();) { Object o = iterator.next(); String s = o.toString(); result += s; if (iterator.hasNext()) { if (withSpacing) result += ", "; else result += ","; } } return result; }
From source file:com.ms.commons.test.common.OutputUtil.java
public static void append(Object object) { append((object == null) ? "null" : object.toString()); }
From source file:Main.java
public static String objectString(Object value) { if (value == null || "".equals(value)) { return ""; } else {//from ww w . ja v a 2 s.c o m return value.toString(); } }
From source file:org.n52.restfulwpsproxy.serializer.json.AbstractWPSJsonModule.java
protected static final String toStringOrNull(Object object) { return object == null ? null : object.toString(); }