List of usage examples for java.lang Object toString
public String toString()
From source file:Main.java
/** * Convert collection to string.// w w w.j a v a2 s. c o m * * @param items the items * @return the string */ public static String convertCollectionToString(Iterable<?> items) { final StringBuilder sb = new StringBuilder(); String sep = ""; for (final Object item : items) { sb.append(sep).append(item.toString()); sep = ", "; } return sb.toString(); }
From source file:Main.java
/** * Checks if the given list contains a specific object value by comparing the * string version.//from w w w . j av a 2s. c om * * This is necessary becuase we sometimes don't want to work with exactly * the same instance on the client side but with a temp. instance which * is fetched on demand but reperesents the same object * * @param list * @param obj * @return */ public static boolean contains(List list, Object obj) { for (Object entry : list) { if (entry.toString().equals(obj.toString())) return true; } return false; }
From source file:Main.java
private static int getArrayDimension(Object object) { int dim = 0;//from w w w .j av a 2 s . co m for (int i = 0; i < object.toString().length(); ++i) { if (object.toString().charAt(i) == '[') { ++dim; } else { break; } } return dim; }
From source file:Main.java
public static int getArrayDimension(Object object) { int dim = 0;// w ww . j a v a 2 s . c o m for (int i = 0; i < object.toString().length(); ++i) { if (object.toString().charAt(i) == '[') { ++dim; } else { break; } } return dim; }
From source file:Main.java
public static Map<String, String> propertiesToMap(Properties properties) { final Map<String, String> result = new HashMap<String, String>(); for (final Object propKey : properties.keySet()) { result.put(propKey.toString(), properties.getProperty(propKey.toString())); }// w w w . j a v a 2s. com return result; }
From source file:Main.java
public static double doDouble(Object obj, double defValue) { return obj != null ? Double.parseDouble(obj.toString()) : defValue; }
From source file:Main.java
/** * Returns the node with the given text below the given node in the specified TreeModel * @param model/*from w w w.ja v a 2s.c o m*/ * the TreeModel to search * @param node * the node to search below * @param text * the text associated with the required node * @return * the required node, if found; otherwise null */ static Object findChildNode(TreeModel model, Object node, String text) { for (int i = 0; i < model.getChildCount(node); i++) { Object currNode = model.getChild(node, i); if (currNode.toString() != null && currNode.toString().equals(text)) return currNode; } return null; }
From source file:Main.java
/** * Converts a {@link Collection} to a {@link String} separating entries by * <code>, </code>./*ww w.j a v a2 s. c o m*/ */ public static String toString(Collection<?> collection) { final StringBuffer string = new StringBuffer(); for (final Object object : collection) { string.append(object.toString()); string.append(", "); } string.delete(string.length() - 2, string.length()); return string.toString(); }
From source file:Main.java
public static List<Integer> sort(List<Integer> srcList) { Object[] ary = srcList.toArray(); java.util.Arrays.sort(ary);//from ww w. j ava 2 s .c o m List<Integer> resultList = new ArrayList<Integer>(); for (Object val : ary) { resultList.add(Integer.parseInt(val.toString())); } return resultList; }
From source file:Main.java
private static char getType(Object object) { if (isArray(object)) { String str = object.toString(); return str.substring(str.lastIndexOf("[") + 1, str.lastIndexOf("[") + 2).charAt(0); }//from ww w .ja v a 2 s .co m return 0; }