Added ArrayUtil.safeToString(), which encapsulates the logic to check if it's an array.
git-svn-id: https://samskivert.googlecode.com/svn/trunk@2970 6335cc39-0255-0410-8fd6-9bcaacd3b74c
This commit is contained in:
@@ -908,7 +908,15 @@ public class ArrayUtil
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String representation of the specified Object, which must be an array.
|
||||
* Return the String representation of the specified Object, which may or may not be an array.
|
||||
*/
|
||||
public static String safeToString (Object o)
|
||||
{
|
||||
return ((o == null) || !o.getClass().isArray()) ? String.valueOf(o) : toString(o);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the String representation of the specified Object, which <em>must</em> be an array.
|
||||
*
|
||||
* @throws IllegalArgumentException if array is not actually an array.
|
||||
*/
|
||||
|
||||
@@ -63,9 +63,7 @@ public class LogBuilder
|
||||
}
|
||||
_log.append(args[ii]).append('=');
|
||||
try {
|
||||
Object arg = args[ii + 1];
|
||||
_log.append(((arg == null) || !arg.getClass().isArray())
|
||||
? arg : ArrayUtil.toString(arg));
|
||||
_log.append(ArrayUtil.safeToString(args[ii + 1]));
|
||||
} catch (Throwable t) {
|
||||
_log.append("<toString() failure: ").append(t).append('>');
|
||||
}
|
||||
|
||||
@@ -157,10 +157,7 @@ public abstract class Logger
|
||||
}
|
||||
buf.append(args[ii]).append('=');
|
||||
try {
|
||||
Object arg = args[ii + 1];
|
||||
buf.append(((arg == null) || !arg.getClass().isArray())
|
||||
? arg
|
||||
: ArrayUtil.toString(arg));
|
||||
buf.append(ArrayUtil.safeToString(args[ii + 1]));
|
||||
} catch (Throwable t) {
|
||||
buf.append("<toString() failure: ").append(t).append(">");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user