You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by rd...@apache.org on 2005/08/06 12:34:07 UTC
svn commit: r230543 - in /jakarta/commons/proper/betwixt/trunk:
src/java/org/apache/commons/betwixt/io/BeanWriter.java
src/test/org/apache/commons/betwixt/io/TestPrettyPrint.java xdocs/tasks.xml
Author: rdonkin
Date: Sat Aug 6 03:33:57 2005
New Revision: 230543
URL: http://svn.apache.org/viewcvs?rev=230543&view=rev
Log:
Fixed issue when pretty printing empty elements. Thanks to Ivano for an accurate diagnosis. Issue #35970.
Added:
jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/io/TestPrettyPrint.java
Modified:
jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/BeanWriter.java
jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml
Modified: jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/BeanWriter.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/BeanWriter.java?rev=230543&r1=230542&r2=230543&view=diff
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/BeanWriter.java (original)
+++ jakarta/commons/proper/betwixt/trunk/src/java/org/apache/commons/betwixt/io/BeanWriter.java Sat Aug 6 03:33:57 2005
@@ -433,14 +433,15 @@
closedStartTag = true;
} else {
- if (!currentElementHasBodyText) {
- indent();
- }
+
if (
addEndTagForEmptyElement
&& !closedStartTag ) {
writer.write( ">" );
closedStartTag = true;
+ }
+ else if (!currentElementHasBodyText) {
+ indent();
}
writer.write( "</" );
writer.write( qualifiedName );
Added: jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/io/TestPrettyPrint.java
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/io/TestPrettyPrint.java?rev=230543&view=auto
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/io/TestPrettyPrint.java (added)
+++ jakarta/commons/proper/betwixt/trunk/src/test/org/apache/commons/betwixt/io/TestPrettyPrint.java Sat Aug 6 03:33:57 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright 2005 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.betwixt.io;
+
+import java.io.StringWriter;
+
+import org.apache.commons.betwixt.AbstractTestCase;
+import org.apache.commons.betwixt.ElementDescriptor;
+import org.xml.sax.helpers.AttributesImpl;
+
+
+public class TestPrettyPrint extends AbstractTestCase {
+
+ public TestPrettyPrint(String testName) {
+ super(testName);
+ }
+
+ public void testEndElement() throws Exception {
+ StringWriter out = new StringWriter();
+ BeanWriter writer = new BeanWriter(out);
+ writer.enablePrettyPrint();
+ writer.setEndTagForEmptyElement(true);
+
+ WriteContext context = new WriteContext() {
+
+ public ElementDescriptor getCurrentDescriptor() {
+ return null;
+ }
+
+ };
+
+ writer.startElement(context, "", "emptytag", "emptytag", new AttributesImpl());
+ writer.endElement(context, "", "emptytag", "emptytag");
+
+ assertEquals("", "<emptytag></emptytag>", out.toString().trim());
+ }
+}
Modified: jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml
URL: http://svn.apache.org/viewcvs/jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml?rev=230543&r1=230542&r2=230543&view=diff
==============================================================================
--- jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml (original)
+++ jakarta/commons/proper/betwixt/trunk/xdocs/tasks.xml Sat Aug 6 03:33:57 2005
@@ -200,6 +200,9 @@
<subsection name='Since 0.7'>
<ul>
<li>
+Fixed formatting bug when pretty printing elements with <code>endTagForEmptyElement</code> is true.
+ </li>
+ <li>
Made intitial indent level used for pretty printing configurable.
</li>
<li>Added guess-name attribute to addDefaults element in dot betwixt file.
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org