Skip to content

Commit 560bb3f

Browse files
committed
Minor improvements
1 parent 52e02a5 commit 560bb3f

3 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/main/java/tools/jackson/dataformat/xml/ser/ToXmlGenerator.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ public class ToXmlGenerator
100100
*/
101101

102102
/**
103+
* Document Type Declaration to write, if any; {@code null} if none.
104+
*
103105
* @since 3.2
104106
*/
105107
protected DTD _dtd;

src/main/java/tools/jackson/dataformat/xml/ser/XmlGeneratorInitializer.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,13 +29,13 @@ public void initialize(SerializationConfig config, JsonGenerator g) throws Jacks
2929
}
3030
}
3131

32-
public XmlGeneratorInitializer withDTD(String rootName,
32+
public XmlGeneratorInitializer setDTD(String rootName,
3333
String systemId, String publicId,
3434
String internalSubset) {
35-
return withDTD(new DTD(rootName, systemId, publicId, internalSubset));
35+
return setDTD(new DTD(rootName, systemId, publicId, internalSubset));
3636
}
3737

38-
public XmlGeneratorInitializer withDTD(DTD dtd) {
38+
public XmlGeneratorInitializer setDTD(DTD dtd) {
3939
_dtd = dtd;
4040
return this;
4141
}

src/test/java/tools/jackson/dataformat/xml/ser/XmlGeneratorInitializerTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public void testDTDWithPublicId() throws Exception
1919
{
2020
ObjectWriter w = MAPPER.writer().with(
2121
new XmlGeneratorInitializer()
22-
.withDTD("StringBean", "system", "http://foo.bar", ""));
22+
.setDTD("StringBean", "system", "http://foo.bar", ""));
2323
assertEquals(a2q("<!DOCTYPE StringBean PUBLIC 'http://foo.bar' 'system'>"
2424
+"<StringBean><text>test</text></StringBean>"),
2525
w.writeValueAsString(new StringBean("test")));
@@ -30,7 +30,7 @@ public void testDTDWithSystemIdOnly() throws Exception
3030
{
3131
ObjectWriter w = MAPPER.writer().with(
3232
new XmlGeneratorInitializer()
33-
.withDTD("StringBean", "system", "", null));
33+
.setDTD("StringBean", "system", "", null));
3434
assertEquals(a2q("<!DOCTYPE StringBean SYSTEM 'system'>"
3535
+"<StringBean><text>test</text></StringBean>"),
3636
w.writeValueAsString(new StringBean("test")));
@@ -41,7 +41,7 @@ public void testDTDWithInternalSubset() throws Exception
4141
{
4242
ObjectWriter w = MAPPER.writer().with(
4343
new XmlGeneratorInitializer()
44-
.withDTD("StringBean", "system", "http://foo.bar", "<!ELEMENT root (#PCDATA)>"));
44+
.setDTD("StringBean", "system", "http://foo.bar", "<!ELEMENT root (#PCDATA)>"));
4545
assertEquals(a2q("<!DOCTYPE StringBean PUBLIC 'http://foo.bar' 'system' "
4646
+"[<!ELEMENT root (#PCDATA)>]>"
4747
+"<StringBean><text>test</text></StringBean>"),
@@ -54,7 +54,7 @@ public void testDTDInvalidNoRoot() throws Exception
5454
try {
5555
/*ObjectWriter w =*/ MAPPER.writer().with(
5656
new XmlGeneratorInitializer()
57-
.withDTD("", null, null, null));
57+
.setDTD("", null, null, null));
5858
fail("Should not pass");
5959
} catch (IllegalArgumentException e) {
6060
verifyException(e, "Illegal argument for 'rootName': must be");

0 commit comments

Comments
 (0)