diff --git a/src/java/org/apache/commons/collections/MapUtils.java b/src/java/org/apache/commons/collections/MapUtils.java
index ea14dc79f..0748887cf 100644
--- a/src/java/org/apache/commons/collections/MapUtils.java
+++ b/src/java/org/apache/commons/collections/MapUtils.java
@@ -1,5 +1,5 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/MapUtils.java,v 1.31 2003/08/31 17:26:43 scolebourne Exp $
+ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/java/org/apache/commons/collections/MapUtils.java,v 1.32 2003/08/31 17:52:13 scolebourne Exp $
* ====================================================================
*
* The Apache Software License, Version 1.1
@@ -105,7 +105,7 @@ import org.apache.commons.collections.decorators.TypedSortedMap;
*
*
* @since Commons Collections 1.0
- * @version $Revision: 1.31 $ $Date: 2003/08/31 17:26:43 $
+ * @version $Revision: 1.32 $ $Date: 2003/08/31 17:52:13 $
*
* @author James Strachan
* @author Nissim Karpenstein
@@ -686,11 +686,11 @@ public class MapUtils {
* When the value is a Map, recursive behaviour occurs.
*
* @param out the stream to print to, must not be null
- * @param label the label to be applied to the output generated. This
- * may well be the key associated with this map within a
- * surrounding map in which this is nested. If the label is
- * null
then no label is output.
- * @param map the map to print, may be null
+ * @param label The label to be used, may be null
.
+ * If null
, the label is not output.
+ * It typically represents the name of the property in a bean or similar.
+ * @param map The map to print, may be null
.
+ * If null
, the text 'null' is output.
* @throws NullPointerException if the stream is null
*/
public static synchronized void verbosePrint(
@@ -710,11 +710,11 @@ public class MapUtils {
* When the value is a Map, recursive behaviour occurs.
*
* @param out the stream to print to, must not be null
- * @param label the label to be applied to the output generated. This
- * may well be the key associated with this map within a
- * surrounding map in which this is nested. If the label is
- * null
then no label is output.
- * @param map the map to print, may be null
+ * @param label The label to be used, may be null
.
+ * If null
, the label is not output.
+ * It typically represents the name of the property in a bean or similar.
+ * @param map The map to print, may be null
.
+ * If null
, the text 'null' is output.
* @throws NullPointerException if the stream is null
*/
public static synchronized void debugPrint(
@@ -756,11 +756,11 @@ public class MapUtils {
* value.
*
* @param out the stream to print to
- * @param label the label to be applied to the output generated. This
- * may well be the key associated with this map within a
- * surrounding map in which this is nested. If the label is
- * null
, then it is not output.
- * @param map the map to print, may be null
+ * @param label The label to be used, may be null
.
+ * If null
, the label is not output.
+ * It typically represents the name of the property in a bean or similar.
+ * @param map The map to print, may be null
.
+ * If null
, the text 'null' is output.
* @param debug flag indicating whether type names should be output.
* @throws NullPointerException if the stream is null
*/
@@ -772,13 +772,17 @@ public class MapUtils {
printIndent(out);
+ if (map == null) {
+ if (label != null) {
+ out.print(label);
+ out.print(" = ");
+ }
+ out.println("null");
+ return;
+ }
if (label != null) {
out.print(label);
- out.print(" = ");
- out.println(map == null ? "null" : "");
- }
- if (map == null) {
- return;
+ out.println(" = ");
}
printIndent(out);
diff --git a/src/test/org/apache/commons/collections/TestMapUtils.java b/src/test/org/apache/commons/collections/TestMapUtils.java
index 52a491aa6..975645e06 100644
--- a/src/test/org/apache/commons/collections/TestMapUtils.java
+++ b/src/test/org/apache/commons/collections/TestMapUtils.java
@@ -1,5 +1,5 @@
/*
- * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestMapUtils.java,v 1.9 2003/08/31 17:28:43 scolebourne Exp $
+ * $Header: /home/jerenkrantz/tmp/commons/commons-convert/cvs/home/cvs/jakarta-commons//collections/src/test/org/apache/commons/collections/TestMapUtils.java,v 1.10 2003/08/31 17:52:13 scolebourne Exp $
* ====================================================================
*
* The Apache Software License, Version 1.1
@@ -73,7 +73,7 @@ import junit.framework.Test;
/**
* Tests for MapUtils.
*
- * @version $Revision: 1.9 $ $Date: 2003/08/31 17:28:43 $
+ * @version $Revision: 1.10 $ $Date: 2003/08/31 17:52:13 $
*
* @author Stephen Colebourne
* @author Arun Mammen Thomas
@@ -400,17 +400,25 @@ public class TestMapUtils extends BulkTest {
public void testVerbosePrintNullLabelAndMap() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
+
+ outPrint.println("null");
+ final String EXPECTED_OUT = out.toString();
+ out.reset();
MapUtils.verbosePrint(outPrint, null, null);
- assertEquals("", out.toString());
+ assertEquals(EXPECTED_OUT, out.toString());
}
public void testDebugPrintNullLabelAndMap() {
final ByteArrayOutputStream out = new ByteArrayOutputStream();
final PrintStream outPrint = new PrintStream(out);
+ outPrint.println("null");
+ final String EXPECTED_OUT = out.toString();
+ out.reset();
+
MapUtils.debugPrint(outPrint, null, null);
- assertEquals("", out.toString());
+ assertEquals(EXPECTED_OUT, out.toString());
}
public void testVerbosePrintNullStream() {