Bug 1650330 - Ensure every Locator is also a Locator2 (#10). DONTBUILD NPOTB r=alchen

* Replace org.xml.sax.helpers.LocatorImpl with nu.validator.htmlparser.impl.LocatorImpl

* instanceof before cast to Locator2

Differential Revision: https://phabricator.services.mozilla.com/D82153
This commit is contained in:
Mike Bremford 2020-08-03 12:30:12 +00:00
Родитель 8932345bb3
Коммит f58ab49971
1 изменённых файлов: 20 добавлений и 1 удалений

Просмотреть файл

@ -37,6 +37,7 @@ package nu.validator.htmlparser.impl;
import org.xml.sax.ErrorHandler;
import org.xml.sax.Locator;
import org.xml.sax.ext.Locator2;
import org.xml.sax.SAXException;
import org.xml.sax.SAXParseException;
@ -66,7 +67,7 @@ import nu.validator.htmlparser.common.XmlViolationPolicy;
* @version $Id$
* @author hsivonen
*/
public class Tokenizer implements Locator {
public class Tokenizer implements Locator, Locator2 {
private static final int DATA_AND_RCDATA_MASK = ~1;
@ -864,6 +865,24 @@ public class Tokenizer implements Locator {
return systemId;
}
/**
* @see org.xml.sax.ext.Locator2#getXMLVersion()
*/
public String getXMLVersion() {
return "1.0";
}
/**
* @see org.xml.sax.ext.Locator2#getXMLVersion()
*/
public String getEncoding() {
try {
return encodingDeclarationHandler == null ? null : encodingDeclarationHandler.getCharacterEncoding();
} catch (SAXException e) {
return null;
}
}
// end Locator impl
// end public API