From 8c9c2a42b0fb1c33e93c9d9fc1e14434c674ad1a Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Wed, 1 Jun 2011 12:15:28 -0700 Subject: [PATCH] - Added missing handling for char[] in toString. - Fixed wacky use of short index variable in toString's short[] handling. - Ensured that custom separator and whether or not we're traversing collections is properly passed to recursive calls. --- .../java/com/samskivert/util/StringUtil.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/samskivert/util/StringUtil.java b/src/main/java/com/samskivert/util/StringUtil.java index 6ce021a4..a729b302 100644 --- a/src/main/java/com/samskivert/util/StringUtil.java +++ b/src/main/java/com/samskivert/util/StringUtil.java @@ -1273,7 +1273,18 @@ public class StringUtil } else if (val instanceof short[]) { buf.append(openBox); short[] v = (short[])val; - for (short i = 0; i < v.length; i++) { + for (int i = 0; i < v.length; i++) { + if (i > 0) { + buf.append(sep); + } + buf.append(v[i]); + } + buf.append(closeBox); + + } else if (val instanceof char[]) { + buf.append(openBox); + char[] v = (char[])val; + for (int i = 0; i < v.length; i++) { if (i > 0) { buf.append(sep); } @@ -1332,7 +1343,7 @@ public class StringUtil if (i > 0) { buf.append(sep); } - toString(buf, v[i], openBox, closeBox); + toString(buf, v[i], openBox, closeBox, sep, traverseCollections); } buf.append(closeBox); @@ -1377,7 +1388,7 @@ public class StringUtil if (i > 0) { buf.append(sep); } - toString(buf, iter.next(), openBox, closeBox); + toString(buf, iter.next(), openBox, closeBox, sep, true); } buf.append(closeBox); @@ -1388,7 +1399,7 @@ public class StringUtil if (i > 0) { buf.append(sep); } - toString(buf, enm.nextElement(), openBox, closeBox); + toString(buf, enm.nextElement(), openBox, closeBox, sep, true); } buf.append(closeBox);