commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From scolebou...@apache.org
Subject cvs commit: jakarta-commons/collections/src/java/org/apache/commons/collections MapUtils.java
Date Sun, 31 Aug 2003 17:52:13 GMT
scolebourne    2003/08/31 10:52:13

  Modified:    collections/src/test/org/apache/commons/collections
                        TestMapUtils.java
               collections/src/java/org/apache/commons/collections
                        MapUtils.java
  Log:
  Update the MapUtils to output 'null' if null map
  bug 20740
  
  Revision  Changes    Path
  1.10      +12 -4     jakarta-commons/collections/src/test/org/apache/commons/collections/TestMapUtils.java
  
  Index: TestMapUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/test/org/apache/commons/collections/TestMapUtils.java,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- TestMapUtils.java	31 Aug 2003 17:28:43 -0000	1.9
  +++ TestMapUtils.java	31 Aug 2003 17:52:13 -0000	1.10
  @@ -400,17 +400,25 @@
       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() {
  
  
  
  1.32      +26 -22    jakarta-commons/collections/src/java/org/apache/commons/collections/MapUtils.java
  
  Index: MapUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons/collections/src/java/org/apache/commons/collections/MapUtils.java,v
  retrieving revision 1.31
  retrieving revision 1.32
  diff -u -r1.31 -r1.32
  --- MapUtils.java	31 Aug 2003 17:26:43 -0000	1.31
  +++ MapUtils.java	31 Aug 2003 17:52:13 -0000	1.32
  @@ -686,11 +686,11 @@
        * 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 
  -     *              <code>null</code> then no label is output.
  -     * @param map  the map to print, may be <code>null</code>
  +     * @param label  The label to be used, may be <code>null</code>.
  +     *  If <code>null</code>, 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 <code>null</code>.
  +     *  If <code>null</code>, the text 'null' is output.
        * @throws NullPointerException if the stream is <code>null</code>
        */
       public static synchronized void verbosePrint(
  @@ -710,11 +710,11 @@
        * 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 
  -     *              <code>null</code> then no label is output.
  -     * @param map  the map to print, may be <code>null</code>
  +     * @param label  The label to be used, may be <code>null</code>.
  +     *  If <code>null</code>, 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 <code>null</code>.
  +     *  If <code>null</code>, the text 'null' is output.
        * @throws NullPointerException if the stream is <code>null</code>
        */
       public static synchronized void debugPrint(
  @@ -756,11 +756,11 @@
        * 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 
  -     *              <code>null</code>, then it is not output.
  -     * @param map  the map to print, may be <code>null</code>
  +     * @param label  The label to be used, may be <code>null</code>.
  +     *  If <code>null</code>, 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 <code>null</code>.
  +     *  If <code>null</code>, the text 'null' is output.
        * @param debug flag indicating whether type names should be output.
        * @throws NullPointerException if the stream is <code>null</code>
        */
  @@ -772,13 +772,17 @@
   
           printIndent(out);
   
  -        if (label != null) {
  -            out.print(label);
  -            out.print(" = ");
  -            out.println(map == null ? "null" : "");
  -        }
           if (map == null) {
  +            if (label != null) {
  +                out.print(label);
  +                out.print(" = ");
  +            }
  +            out.println("null");
               return;
  +        }
  +        if (label != null) {
  +            out.print(label);
  +            out.println(" = ");
           }
   
           printIndent(out);
  
  
  

Mime
View raw message