Polishing

This commit is contained in:
Juergen Hoeller
2020-05-14 00:23:20 +02:00
parent 8212aaf3bb
commit fe33822fa7
8 changed files with 34 additions and 30 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2018 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.ext.Locator2;
import org.xml.sax.helpers.AttributesImpl;
@@ -163,9 +164,11 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
this.encoding = startDocument.getCharacterEncodingScheme();
}
}
if (getContentHandler() != null) {
ContentHandler contentHandler = getContentHandler();
if (contentHandler != null) {
final Location location = event.getLocation();
getContentHandler().setDocumentLocator(new Locator2() {
contentHandler.setDocumentLocator(new Locator2() {
@Override
public int getColumnNumber() {
return (location != null ? location.getColumnNumber() : -1);
@@ -194,7 +197,7 @@ class StaxEventXMLReader extends AbstractStaxXMLReader {
return encoding;
}
});
getContentHandler().startDocument();
contentHandler.startDocument();
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import org.xml.sax.Attributes;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
import org.xml.sax.ext.Locator2;
import org.xml.sax.helpers.AttributesImpl;
@@ -139,9 +140,11 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
}
this.encoding = this.reader.getCharacterEncodingScheme();
}
if (getContentHandler() != null) {
ContentHandler contentHandler = getContentHandler();
if (contentHandler != null) {
final Location location = this.reader.getLocation();
getContentHandler().setDocumentLocator(new Locator2() {
contentHandler.setDocumentLocator(new Locator2() {
@Override
public int getColumnNumber() {
return (location != null ? location.getColumnNumber() : -1);
@@ -170,7 +173,7 @@ class StaxStreamXMLReader extends AbstractStaxXMLReader {
return encoding;
}
});
getContentHandler().startDocument();
contentHandler.startDocument();
if (this.reader.standaloneSet()) {
setStandalone(this.reader.isStandalone());
}