List of usage examples for java.lang Object toString
public String toString()
From source file:Main.java
public static String getNiceList(Collection<?> collection, String separator) { StringBuilder result = new StringBuilder(); for (Object value : collection) { if (result.length() > 0) { result.append(separator);/*from w w w.ja va 2s . c om*/ } result.append(value.toString()); } return result.toString(); }
From source file:com.linkedin.pinot.core.segment.index.loader.LoaderUtils.java
/** * Get string list from segment properties. * <p>/* ww w . j a v a 2 s . co m*/ * NOTE: When the property associated with the key is empty, {@link PropertiesConfiguration#getList(String)} will * return an empty string singleton list. Using this method will return an empty list instead. * * @param key property key. * @return string list value for the property. */ public static List<String> getStringListFromSegmentProperties(String key, PropertiesConfiguration segmentProperties) { List<String> stringList = new ArrayList<>(); List propertyList = segmentProperties.getList(key); if (propertyList != null) { for (Object value : propertyList) { String stringValue = value.toString(); if (!stringValue.isEmpty()) { stringList.add(stringValue); } } } return stringList; }
From source file:com.mikecorrigan.bohrium.pubsub.JSONCodec.java
public static JSONObject toJson(final Bundle bundle) { Log.v(TAG, "toJson"); JSONObject j = new JSONObject(); try {//from www. j a va 2 s.c om for (final String key : bundle.keySet()) { final Object value = bundle.get(key); Log.v(TAG, "key=" + key + ", value=" + value.toString()); j.put(key, value.toString()); } return j; } catch (JSONException e) { Log.e(TAG, "exception=" + e); Log.e(TAG, Log.getStackTraceString(e)); } return null; }
From source file:Main.java
public static void mapToAndroidLayoutMapper(Class classObj, Map map, String prefixStr, Activity view) { if (map == null) { return;//from w ww. j a v a 2 s .c o m } for (Object keyObj : map.keySet().toArray()) { String keyStr = keyObj.toString(); Field fieldObj = null; try { fieldObj = classObj.getField(prefixStr + "_" + keyStr); } catch (NoSuchFieldException e) { continue; } Object layoutObj = null; try { layoutObj = fieldObj.get(fieldObj); } catch (IllegalAccessException e) { continue; } Integer layoutIntvalue = (Integer) layoutObj; View selectedView = view.findViewById(layoutIntvalue); if (selectedView instanceof TextView) { TextView textView = (TextView) selectedView; textView.setText((String) map.get(keyStr)); } else if (selectedView instanceof ImageView) { ImageView imageView = (ImageView) selectedView; } } }
From source file:com.kappaware.logtrawler.Utils.java
public static String toString(Object o) { return (o == null) ? null : o.toString(); }
From source file:com.whizzosoftware.hobson.rest.v1.util.URLVariableParser.java
/** * Parse a String value into a URLInfo object. * * @param value the String value to parse * * @return a URIInfo object/*from w w w .j a va2 s . com*/ * @throws ParseException on failure * @throws URISyntaxException on failure */ public static URIInfo parse(String value) throws ParseException, URISyntaxException { String ts = value.trim(); // assume that value starting with '{' is a JSON object if (ts.charAt(0) == '{') { JSONObject json = new JSONObject(new JSONTokener(value)); // "url" is a required pair if (!json.has(PROP_URL)) { throw new ParseException("'url' is a required key in JSON object", 0); } URIInfo info = new URIInfo(json.getString(PROP_URL)); // add headers if any are defined if (json.has(PROP_HEADERS)) { JSONObject headers = json.getJSONObject(PROP_HEADERS); for (Object o : headers.keySet()) { String key = o.toString(); info.addHeader(key, headers.getString(key)); } } // add auth information if any is defined if (json.has(PROP_AUTH)) { JSONObject auth = json.getJSONObject(PROP_AUTH); if (!auth.has(PROP_USERNAME) || !auth.has(PROP_PASSWORD) || !auth.has(PROP_TYPE)) { throw new ParseException("'username', 'password' and 'type' are required in 'auth' JSON object", 0); } info.setAuthInfo(new URLAuthInfo(auth.getString(PROP_USERNAME), auth.getString(PROP_PASSWORD), auth.getString(PROP_TYPE))); } return info; // otherwise, simply treat the value as a full URL } else { return new URIInfo(ts); } }
From source file:com.qagen.osfe.core.utils.ValueToString.java
private static String formatNumber(Object value, String pattern) { return (pattern != null) ? NumberFormatter.formatNumber(value, pattern) : value.toString(); }
From source file:Main.java
public static String toString(Map<?, ?> m, String prefix) { if (m == null) { return "null"; }/*from ww w .j a va 2 s . c o m*/ StringBuilder sb = new StringBuilder(); String sep = ""; for (Object object : m.keySet()) { Object value = m.get(object); sb.append(sep).append(prefix).append(object.toString()).append(arrow).append(value.toString()); sep = separator; } return sb.toString(); }
From source file:cn.edu.hfut.dmic.webcollector.util.CrawlDatumFormater.java
public static CrawlDatum jsonStrToDatum(String crawlDatumKey, String str) { JSONArray jsonArray = new JSONArray(str); CrawlDatum crawlDatum = new CrawlDatum(); crawlDatum.key(crawlDatumKey);/*from www . j ava 2 s . c o m*/ crawlDatum.url(jsonArray.getString(0)); crawlDatum.setStatus(jsonArray.getInt(1)); crawlDatum.setExecuteTime(jsonArray.getLong(2)); crawlDatum.setExecuteCount(jsonArray.getInt(3)); if (jsonArray.length() == 5) { JSONObject metaJSONObject = jsonArray.getJSONObject(4); for (Object keyObject : metaJSONObject.keySet()) { String key = keyObject.toString(); String value = metaJSONObject.getString(key); crawlDatum.meta(key, value); } } return crawlDatum; }
From source file:es.chatclient.styles.CssGenerator.java
private static String replaceConstants(File f) { FileInputStream fis;/*w w w . j a v a 2 s. c om*/ try { fis = new FileInputStream(f); String content = IOUtils.toString(fis, Charset.defaultCharset()); for (Object key : propCss.keySet()) { content = content.replaceAll(key.toString(), propCss.get(key).toString()); } fis.close(); return content; } catch (FileNotFoundException ex) { Logger.getLogger(CssGenerator.class.getName()).log(Level.SEVERE, null, ex); } catch (IOException ex) { Logger.getLogger(CssGenerator.class.getName()).log(Level.SEVERE, null, ex); } return null; }