List of usage examples for java.lang Object toString
public String toString()
From source file:Main.java
private static String internalJoin(String sep, Collection<Object> pieces) { StringBuilder sb = new StringBuilder(); boolean skipSep = true; Iterator<Object> iter = pieces.iterator(); while (iter.hasNext()) { if (skipSep) { skipSep = false;/*from www. ja v a2 s . co m*/ } else { sb.append(sep); } Object obj = iter.next(); if (obj == null) { sb.append("null"); } else { sb.append(obj.toString()); } } return sb.toString(); }
From source file:Main.java
/** * Join collection using custom delimiter * * @param collection A collection to join * @param delimiter Custom join delimiter * @return Joined collection as string//from ww w.j a v a 2 s.c o m */ public static String join(Collection<?> collection, String delimiter) { if (collection == null) { return null; } StringBuilder builder = new StringBuilder(); for (Object element : collection) { if (builder.length() > 0) { builder.append(delimiter); } builder.append(element != null ? element.toString() : ""); } return builder.toString(); }
From source file:Main.java
public static void putSharedPref(Context context, String name, Object object) { SharedPreferences prefs = context.getSharedPreferences("TheMovieDb", Context.MODE_PRIVATE); SharedPreferences.Editor editor = prefs.edit(); editor.putString(name, object.toString()); editor.commit();/* w ww. j av a2 s .com*/ }
From source file:Main.java
public static String toString(@NonNull Object[] elements, @NonNull String delimiter) { final StringBuilder builder = new StringBuilder(); boolean nonFirst = false; for (Object o : elements) { if (nonFirst) { builder.append(delimiter);//www. j av a2s . com } else { nonFirst = true; } builder.append(o.toString()); } return builder.toString(); }
From source file:PrefsUtil.java
/** * Puts a list into the preferences starting with "0" then "1" */// w w w .j av a 2s . c om public static void putList(Preferences preferences, List list) { if (preferences == null) { throw new IllegalArgumentException("Preferences not set."); } //System.out.println( "LIST=" + list ); for (int index = 0; list != null && index < list.size(); index++) { Object value = list.get(index); preferences.put("" + index, value == null ? null : value.toString()); } }
From source file:Main.java
public static Element createCDATAElement(String name, Object value, Document doc) { Element element = doc.createElement(name); element.appendChild(doc.createCDATASection(value.toString())); return element; }
From source file:org.eclipse.virgo.ide.beans.core.internal.locate.SpringOsgiConfigLocationUtils.java
/** * Return the {@value #SPRING_CONTEXT_HEADER} if present from the given dictionary. *///from www . java2 s . c o m public static String getSpringContextHeader(Dictionary<String, String> headers) { Object header = null; if (headers != null) header = headers.get(SPRING_CONTEXT_HEADER); return (header != null ? header.toString().trim() : null); }
From source file:com.zenoss.zenpacks.zenjmx.call.Utility.java
/** * Downcasts the Object[] to a List<String> * @param source the Objects to downcast to their String representation * @return a List<String> that is the result of calling toString() * on each Object in the source/*from ww w . j ava 2 s.c om*/ */ public static List<String> downcast(Object[] source) { List<String> dest = new ArrayList<String>(); if (source != null) { for (Object obj : source) { dest.add(obj.toString()); } } return dest; }
From source file:Main.java
public static String toString(Iterable<Object> pathItrb) { LinkedList<Object> list = new LinkedList<Object>(); Iterator itr = pathItrb.iterator(); while (itr.hasNext()) { list.addFirst(itr.next());/* w ww. j av a 2 s . c o m*/ } // StringBuilder sb = new StringBuilder(); boolean isFirst = true; for (Object obj : list) { if (isFirst) { isFirst = false; } else { sb.append("/"); // NOI18N } sb.append(obj.toString()); } // return sb.toString(); }
From source file:io.mindmaps.graql.internal.StringConverter.java
/** * @param value a value in the graph//from w ww . j a va 2 s.c o m * @return the string representation of the value (using quotes if it is already a string) */ public static String valueToString(Object value) { if (value instanceof String) { return quoteString((String) value); } else { return value.toString(); } }