Skip to content

Commit 244e95d

Browse files
authored
Merge pull request #7 from cordisvictor/v1.4.1
v1.4.1: fix XMLWriter text driver empty line when pretty printing
2 parents 1640a29 + 8e2c003 commit 244e95d

File tree

3 files changed

+22
-12
lines changed

3 files changed

+22
-12
lines changed

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,20 @@ EasyML
99
(http://sourceforge.net/projects/kxml/files/kxml2/2.3.0/kxml2-min-2.3.0.jar/download)
1010

1111

12+
!Release 1.4.1
13+
- bugfix: XMLWriter text driver empty line when pretty printing.
14+
15+
1216
!Release 1.4.0
1317
- NON-BACKWARD COMPATIBLE refactor: EasyML now immutable(removed setters).
1418
- feature: EasyMLBuilder for easyml customization.
1519

1620

21+
!Release 1.3.10
22+
- bugfix: XMLWriter text driver empty line when pretty printing.
23+
- javadoc: improvements.
24+
25+
1726
!Release 1.3.9
1827
- feature: EasyML, XMLReader, XMLWriter custom XML root tag setting.
1928
- refactor: source level 1.7 warnings fixed.

easyml/src/net/sourceforge/easyml/XMLWriter.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@
8080
*
8181
* @author Victor Cordis ( cordis.victor at gmail.com)
8282
* @since 1.0
83-
* @version 1.3.9
83+
* @version 1.4.1
8484
*/
8585
public class XMLWriter implements Flushable, Closeable {
8686

@@ -335,13 +335,13 @@ public String toString() {
335335
*/
336336
public static abstract class Driver implements CompositeWriter, Flushable, Closeable {
337337

338-
protected static final int STATE_INITIAL = 0;
339-
protected static final int STATE_START = 1;
340-
protected static final int STATE_VALUE = 2;
341-
protected static final int STATE_VALUE_END = 3;
338+
protected static final byte STATE_INITIAL = 0;
339+
protected static final byte STATE_START = 1;
340+
protected static final byte STATE_VALUE = 2;
341+
protected static final byte STATE_VALUE_END = 3;
342342
private final XMLWriter target;
343343
private String oneTimeUniqueId;
344-
protected int state;
344+
protected byte state;
345345

346346
/**
347347
* Creates a new instance to be used by the <code>target</code>

easyml/src/net/sourceforge/easyml/XMLWriterTextDriver.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
*
3535
* @author Victor Cordis ( cordis.victor at gmail.com)
3636
* @since 1.1.0
37-
* @version 1.3.9
37+
* @version 1.4.1
3838
*/
3939
/* default */ final class XMLWriterTextDriver extends XMLWriter.Driver {
4040

@@ -100,15 +100,16 @@ private void writeAttrEqValue(String attr, String value) throws IOException {
100100
@Override
101101
public void startElement(String name) {
102102
try {
103-
if (this.state == XMLWriter.Driver.STATE_INITIAL) {
104-
this.state = XMLWriter.Driver.STATE_VALUE;
105-
} else if (this.state == XMLWriter.Driver.STATE_START) {
103+
if (this.state == XMLWriter.Driver.STATE_START) {
106104
this.writer.write('>');
107-
this.state = XMLWriter.Driver.STATE_VALUE;
105+
writeIndentedLt();
106+
} else if (this.state == XMLWriter.Driver.STATE_INITIAL) {
107+
this.writer.write('<');
108108
} else if (this.state != XMLWriter.Driver.STATE_VALUE) {
109109
throw new IllegalStateException("cannot write element start");
110+
} else {
111+
writeIndentedLt();
110112
}
111-
writeIndentedLt();
112113
this.writer.write(name);
113114
if (this.hasOneTimeUniqueId()) {
114115
writeAttrEqValue(DTD.ATTRIBUTE_ID, this.oneTimeUniqueId());

0 commit comments

Comments
 (0)