Skip to content

Commit 98b67f9

Browse files
committed
Minor cleanup
1 parent 2ecbbcf commit 98b67f9

File tree

2 files changed

+14
-14
lines changed

2 files changed

+14
-14
lines changed

src/main/java/com/fasterxml/jackson/dataformat/xml/XmlTypeResolverBuilder.java

+4-2
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@ public XmlTypeResolverBuilder(JsonTypeInfo.Value settings) {
3434
@Override
3535
public StdTypeResolverBuilder init(JsonTypeInfo.Id idType, TypeIdResolver idRes)
3636
{
37-
3837
super.init(idType, idRes);
3938
if (_typeProperty != null) {
4039
_typeProperty = StaxUtil.sanitizeXmlTypeName(_typeProperty);
@@ -89,7 +88,6 @@ protected TypeIdResolver idResolver(MapperConfig<?> config,
8988
/**********************************************************************
9089
*/
9190

92-
9391
/**
9492
* Helper method for encoding regular Java class name in form that
9593
* can be used as XML element name.
@@ -138,6 +136,8 @@ protected static String decodeXmlClassName(String className)
138136
protected static class XmlClassNameIdResolver
139137
extends ClassNameIdResolver
140138
{
139+
private static final long serialVersionUID = 2L;
140+
141141
public XmlClassNameIdResolver(JavaType baseType, TypeFactory typeFactory,
142142
PolymorphicTypeValidator ptv)
143143
{
@@ -159,6 +159,8 @@ public JavaType typeFromId(DatabindContext context, String id) throws IOExceptio
159159
protected static class XmlMinimalClassNameIdResolver
160160
extends MinimalClassNameIdResolver
161161
{
162+
private static final long serialVersionUID = 2L;
163+
162164
public XmlMinimalClassNameIdResolver(JavaType baseType, TypeFactory typeFactory,
163165
PolymorphicTypeValidator ptv)
164166
{

src/main/java/com/fasterxml/jackson/dataformat/xml/ser/ToXmlGenerator.java

+10-12
Original file line numberDiff line numberDiff line change
@@ -247,15 +247,18 @@ public void initGenerator() throws IOException
247247
}
248248
_initialized = true;
249249
try {
250+
boolean xmlDeclWritten;
250251
if (Feature.WRITE_XML_1_1.enabledIn(_formatFeatures)) {
251252
_xmlWriter.writeStartDocument("UTF-8", "1.1");
253+
xmlDeclWritten = true;
252254
} else if (Feature.WRITE_XML_DECLARATION.enabledIn(_formatFeatures)) {
253255
_xmlWriter.writeStartDocument("UTF-8", "1.0");
256+
xmlDeclWritten = true;
254257
} else {
255-
return;
258+
xmlDeclWritten = false;
256259
}
257260
// as per [dataformat-xml#172], try adding indentation
258-
if (_xmlPrettyPrinter != null) {
261+
if (xmlDeclWritten && (_xmlPrettyPrinter != null)) {
259262
// ... but only if it is likely to succeed:
260263
if (!_stax2Emulation) {
261264
_xmlPrettyPrinter.writePrologLinefeed(_xmlWriter);
@@ -487,10 +490,11 @@ public void writeRepeatedFieldName() throws IOException
487490
/* JsonGenerator method overrides
488491
/**********************************************************
489492
*/
490-
491-
/* Most overrides in this section are just to make methods final,
492-
* to allow better inlining...
493-
*/
493+
494+
@Override
495+
public void writeFieldName(SerializableString name) throws IOException {
496+
writeFieldName(name.getValue());
497+
}
494498

495499
@Override
496500
public final void writeFieldName(String name) throws IOException
@@ -640,12 +644,6 @@ public final void _handleEndObject() throws IOException
640644
/**********************************************************
641645
*/
642646

643-
@Override
644-
public void writeFieldName(SerializableString name) throws IOException
645-
{
646-
writeFieldName(name.getValue());
647-
}
648-
649647
@Override
650648
public void writeString(String text) throws IOException
651649
{

0 commit comments

Comments
 (0)