Modified toString() such that the no-box-arguments versions do not

automatically traverse collections, but instead simply call toString on them.
The versions that take box arguments (where the developer is clearly expressing
a desire for custom formatted collections) still do the traversal. Moved the
warning that Enumeration and Iterator are consumed into said methods.

Switched LogBuilder to use StringUtil.toString, since it now subsumes the
behavior of ArrayUtil.toString without the undesirable collection munging that
motivated its original creation.

Nixed ArrayUtil.toString/safeToString because they haven't been in the wild
long enough to be likely to have been discovered and used by third parties.
This commit is contained in:
Michael Bayne
2011-06-01 11:40:26 -07:00
parent 49083d9105
commit 881ee30047
6 changed files with 190 additions and 212 deletions
@@ -56,12 +56,12 @@ public class ConfigTest
slist.add(iter.nextElement().toString());
}
Collections.sort(slist);
assertEquals("(sub1, sub2, sub3)", StringUtil.toString(slist));
assertEquals("[sub1, sub2, sub3]", StringUtil.toString(slist));
// check the whole shebang
List<String> list = CollectionUtil.addAll(new ArrayList<String>(), pconfig.keys());
Collections.sort(list);
assertEquals("(prop1, prop2, prop3, prop4, sub.sub1, sub.sub2, sub.sub3)",
assertEquals("[prop1, prop2, prop3, prop4, sub.sub1, sub.sub2, sub.sub3]",
StringUtil.toString(list));
}
}
@@ -114,6 +114,6 @@ public class HashIntMapTest
assertTrue(valuestr + ".equals(" + exvals + ")", valuestr.equals(exvals));
}
protected static final String TEST1 = "(10, 11, 12, 13, 14, 15, 16, 17, 18, 19)";
protected static final String TEST2 = "(10, 11)";
protected static final String TEST1 = "[10, 11, 12, 13, 14, 15, 16, 17, 18, 19]";
protected static final String TEST2 = "[10, 11]";
}