List of usage examples for java.lang Object toString
public String toString()
From source file:Main.java
/** * Returns a pretty-printed version of the collection. * Items will be toString()'ed and separated by commas. * The collection can be optionally delimited by "[]". * /* w w w .j av a2s.c om*/ * @param collection * @param dilimit * @return */ public static String allToString(final Collection<?> collection, boolean delimit) { boolean first = true; StringBuilder bldr = new StringBuilder(delimit ? "[" : ""); for (Object o : collection) { bldr.append((first ? "" : ", ") + o.toString()); first = false; } if (delimit) bldr.append(']'); return bldr.toString(); }
From source file:Main.java
/** * <p>/* w w w . ja v a 2s . co m*/ * Returns either the passed in <code>Object</code> as a String, or, if the <code>Object</code> is <code>null</code> * , a passed in default String. * </p> * * @param obj the Object to check * @param defaultString the default String to return if str is <code>null</code> * @return the passed in string, or the default if it was <code>null</code> */ public static String defaultString(Object obj, String defaultString) { return (obj == null) ? defaultString : obj.toString(); }
From source file:Main.java
public static boolean isEmpty(Object value) { if (value == null) { return true; }/*from w w w.j a v a 2 s . co m*/ return isEmpty(value.toString()); }
From source file:Main.java
/** Returns an alphabetically sorted list of the keys. */ public static Vector getSortedKeyList(Hashtable hashtable) { Vector result = new Vector(); Enumeration keys = hashtable.keys(); while (keys.hasMoreElements()) { result.add(keys.nextElement());/* ww w. ja v a2 s . c o m*/ } Collections.sort(result, new Comparator() { public int compare(Object a, Object b) { String textA = a.toString(); String textB = b.toString(); return textA.compareToIgnoreCase(textB); } }); return result; }
From source file:Main.java
public static String getMetaData(Context context, String key) { try {//from w w w. j a v a2s .c o m ApplicationInfo ai = context.getPackageManager().getApplicationInfo(context.getPackageName(), PackageManager.GET_META_DATA); Object value = ai.metaData.get(key); if (value != null) { return value.toString(); } } catch (Exception ignored) { } return null; }
From source file:com.threewks.thundr.view.jsp.el.StringFunctions.java
public static String upperCase(Object arg) { return arg == null ? null : StringUtils.upperCase(arg.toString()); }
From source file:com.threewks.thundr.view.jsp.el.StringFunctions.java
public static String lowerCase(Object arg) { return arg == null ? null : StringUtils.lowerCase(arg.toString()); }
From source file:Main.java
public static boolean isNumeric(Object obj) { if (obj == null) { return false; }/*from w w w .ja v a 2 s . c o m*/ String str = obj.toString(); int sz = str.length(); for (int i = 0; i < sz; i++) { if (!Character.isDigit(str.charAt(i))) { return false; } } return true; }
From source file:com.threewks.thundr.view.jsp.el.StringFunctions.java
public static String sentenceCase(Object arg) { return arg == null ? null : StringUtils.capitalize(arg.toString()); }
From source file:Main.java
public static HashMap<String, List<Object[]>> getUnitDataMapList(List<Object[]> list, int[] indexnum) { HashMap<String, List<Object[]>> dataMap = new HashMap<String, List<Object[]>>(); for (int i = 0; i < list.size(); i++) { StringBuffer returnStringBuffer = new StringBuffer(); for (int ai = 0; ai < indexnum.length; ai++) { int index = indexnum[ai]; Object obj = list.get(i)[index]; String gunit = obj.toString(); if (ai == 0) { returnStringBuffer.append(gunit); } else { returnStringBuffer.append("(" + gunit + ")"); }/*from w ww. j a va2s . c o m*/ } String unit = returnStringBuffer.toString(); if (dataMap.containsKey(unit)) { dataMap.get(unit).add((Object[]) list.get(i)); } else { ArrayList<Object[]> rowdata = new ArrayList<Object[]>(); rowdata.add((Object[]) list.get(i)); dataMap.put(unit, rowdata); } } return dataMap; }