List of usage examples for java.lang Object toString
public String toString()
From source file:jp.ac.u.tokyo.m.log.LogUtil.java
/** * I make the message which enumerated aParams. <br> * aParams ?????? <br>/* ww w .j av a2s. c o m*/ * * @param aPrefix * * @param aSuffix * * @param aParams * ? * @return aPrefix + (aParams ) + aSuffix ?? */ public static String createMultiParamMessage(String aPrefix, String aSuffix, List<? extends Object> aParams) { StringBuilder tLogTextBuilder = new StringBuilder(); tLogTextBuilder.append(aPrefix); for (Object tCurrentParam : aParams) { tLogTextBuilder.append("\""); tLogTextBuilder.append(tCurrentParam.toString()); tLogTextBuilder.append("\" "); } tLogTextBuilder.append(aSuffix); String tString = tLogTextBuilder.toString(); return tString; }
From source file:net.sf.zekr.common.util.CollectionUtils.java
/** * @param col collection parameter to be returned as array * @return an array of <code>collection.eachElement.toString()</code>. *//*from w ww.j a va 2 s.c om*/ public static String[] toStringArray(Collection<?> col) { String[] s = new String[col.size()]; int i = 0; for (Iterator<?> iter = col.iterator(); iter.hasNext(); i++) { Object element = iter.next(); s[i] = element.toString(); } return s; }
From source file:Main.java
public static String collectionToSlashString(Collection<?> collection) { if (collection != null && collection.size() > 0) { StringBuilder sb = new StringBuilder(); Object obj = null; for (Iterator<?> iterator = collection.iterator(); iterator.hasNext();) { obj = iterator.next();/*from www. ja v a 2 s . c om*/ sb.append(obj.toString()); if (iterator.hasNext()) { sb.append("/"); } } return sb.toString(); } else { return ""; } }
From source file:Main.java
/** * Single dump.// ww w. j ava 2s .c o m * * @param l the l * @return the string */ public static String singleDump(final Object[] l) { final StringBuilder sb = new StringBuilder(); if (l == null) { sb.append("[]"); } else if (l.length == 0) { sb.append("[]"); } else { int cnt = 0; sb.append("["); for (final Object o : l) { if (cnt++ > 0) { sb.append(", "); } sb.append(o.toString()); } sb.append("]"); } return (sb.toString()); }
From source file:Main.java
private static Object convertValType(Object value, Class<?> fieldTypeClass) { Object retVal;//from www . ja va 2 s. c o m if (Long.class == fieldTypeClass || long.class == fieldTypeClass) { retVal = Long.parseLong(value.toString()); } else if (Integer.class == fieldTypeClass || int.class == fieldTypeClass) { retVal = Integer.parseInt(value.toString()); } else if (Float.class == fieldTypeClass || float.class == fieldTypeClass) { retVal = Float.parseFloat(value.toString()); } else if (Double.class == fieldTypeClass || double.class == fieldTypeClass) { retVal = Double.parseDouble(value.toString()); } else { retVal = value; } return retVal; }
From source file:Main.java
/** * Join collection to string with separator. * /*w w w . j ava 2 s. c o m*/ * @param iterator * @param separator * @return array string */ public static String join(Iterable<?> iterable, String separator) { if (iterable == null) { return null; } Iterator<?> iterator = iterable.iterator(); if (!iterator.hasNext()) { return ""; } Object first = iterator.next(); if (!iterator.hasNext()) { return first == null ? "" : first.toString(); } StringBuilder buf = new StringBuilder(256); if (first != null) { buf.append(first); } while (iterator.hasNext()) { buf.append(separator); Object obj = iterator.next(); if (obj != null) { buf.append(obj); } } return buf.toString(); }
From source file:com.norbl.util.StringUtil.java
public static String toStringNull(Object s) { if (s != null) return (s.toString()); else//from www. jav a2 s . co m return ("null"); }
From source file:Main.java
public static String formatSqlValue(Object value) { if (value == null) { return "null"; } else if (value instanceof String) { return String.format("'%s'", value.toString()); } else {//from www .ja v a 2 s.c o m return value.toString(); } }
From source file:biomine.bmvis2.crawling.Databases.java
public static Collection<String> getDatabases() { if (dbs != null) return dbs; try {//from w w w . j a v a 2s .com String url = WebConstants.BIOMINE_URL + "stats/index.cgi?json_action=getdbs"; String cont = URLUtils.getURLContents(new URL(url)); Object arr = JSONValue.parse(cont); if (arr instanceof JSONArray) { JSONArray jarr = (JSONArray) arr; dbs = new ArrayList(); for (Object dbo : jarr) { JSONObject jdb = (JSONObject) dbo; Object no = jdb.get("name"); if (no != null) dbs.add(no.toString()); } Collections.reverse(dbs); return dbs; } } catch (MalformedURLException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (ClassCastException e) { // TODO: handle exception } return Collections.EMPTY_LIST; }
From source file:Main.java
/** * Adds attribute with <code>localName</code> to <code>attributes</code> if * value is not null. Follows the same rules as * {@link AttributesImpl#addAttribute(String, String, String, String, String)} * ./*from w ww. jav a2 s . com*/ * * @param attributes * to add to. * @param localName * of attribute to add. * @param value * to add to attribute. * @since 8.1 */ static public void addAttribute(final AttributesImpl attributes, final String localName, final Object value) { if (null != value) { attributes.addAttribute(XMLConstants.NULL_NS_URI, localName, localName, "", value.toString()); } }