rdonkin     2003/03/04 13:48:11

  Modified:    betwixt/src/java/org/apache/commons/betwixt/io
                        BeanWriter.java
               betwixt/src/test/org/apache/commons/betwixt
                        TestRSSRoundTrip.java
  Log:
  Fixed pretty printing bug i introduced during refactoring
  
  Revision  Changes    Path
  1.16      +10 -2     
jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java
  
  Index: BeanWriter.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/betwixt/src/java/org/apache/commons/betwixt/io/BeanWriter.java,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- BeanWriter.java   27 Feb 2003 19:20:17 -0000      1.15
  +++ BeanWriter.java   4 Mar 2003 21:48:10 -0000       1.16
  @@ -139,6 +139,8 @@
       private Log log = LogFactory.getLog( BeanWriter.class );
       /** Has any content (excluding attributes) been written to the current element 
*/
       private boolean currentElementIsEmpty = false;
  +    /** Has the current element written any body text */
  +    private boolean currentElementHasBodyText = false;
       /** Has the last start tag been closed */
       private boolean closedStartTag = true;
       /** Current level of indentation (starts at 1 with the first element) */
  @@ -334,6 +336,7 @@
           }
           closedStartTag = false;
           currentElementIsEmpty = true;
  +        currentElementHasBodyText = false;
       }
       
       /**
  @@ -360,15 +363,19 @@
               closedStartTag = true;
               
           } else {
  -        
  +            if (!currentElementHasBodyText) {
  +                indent();
  +            }
               writer.write( "</" );
               writer.write( qualifiedName );
               writer.write( '>' );
  -        
  +            
           }
           
           indentLevel--;
           printLine();
  +        
  +        currentElementHasBodyText = false;
       }
   
       /** 
  @@ -390,6 +397,7 @@
               }
               writer.write( XMLUtils.escapeBodyValue(text) );
               currentElementIsEmpty = false;
  +            currentElementHasBodyText = true;
           }
       }
       
  
  
  
  1.6       +8 -1      
jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestRSSRoundTrip.java
  
  Index: TestRSSRoundTrip.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/betwixt/src/test/org/apache/commons/betwixt/TestRSSRoundTrip.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- TestRSSRoundTrip.java     13 Feb 2003 18:41:48 -0000      1.5
  +++ TestRSSRoundTrip.java     4 Mar 2003 21:48:11 -0000       1.6
  @@ -77,6 +77,7 @@
   import org.apache.commons.digester.rss.Channel;
   import org.apache.commons.digester.rss.RSSDigester;
   
  +import org.apache.commons.logging.impl.SimpleLog;
   
   /** Test harness which parses an RSS document using Digester
     * then outputs it using Betwixt, then parses it again with Digester
  @@ -220,11 +221,17 @@
           xmlAssertIsomorphic(
               parseString( xml ), 
               parseFile( "src/test/org/apache/commons/betwixt/rss-example.xml" ));
  -    */
  +        */
       }
       
       protected void write(Object bean, Writer out) throws Exception {
  +        //SimpleLog log = new SimpleLog("[TestRSSRoundTrip:BeanWriter]");
  +        //log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
           BeanWriter writer = new BeanWriter(out);
  +        //writer.setLog(log);
  +        //log = new SimpleLog("[TestRSSRoundTrip:AbstractBeanWriter]");
  +        //log.setLevel(SimpleLog.LOG_LEVEL_TRACE);
  +        //writer.setAbstractBeanWriterLog(log);
           writer.setWriteEmptyElements(true);
           writer.getXMLIntrospector().setAttributesForPrimitives(false);
           writer.setWriteIDs(false);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to