# HG changeset patch # User František Kučera # Date 1402214253 -7200 # Node ID 03f940508c7224ac4ac2ae41e7bbe19a9d68ba29 # Parent ad36a104623fd400986c023be1ecaaabd3f7d445 AltSAXParser as standalone class diff -r ad36a104623f -r 03f940508c72 java/alt2xml-lib-input/src/cz/frantovo/alt2xml/AltSAXParser.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/java/alt2xml-lib-input/src/cz/frantovo/alt2xml/AltSAXParser.java Sun Jun 08 09:57:33 2014 +0200 @@ -0,0 +1,69 @@ +/** + * Alt2XML + * Copyright © 2014 František Kučera (frantovo.cz) + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package cz.frantovo.alt2xml; + +import javax.xml.parsers.SAXParser; +import org.xml.sax.Parser; +import org.xml.sax.SAXException; +import org.xml.sax.SAXNotRecognizedException; +import org.xml.sax.SAXNotSupportedException; +import org.xml.sax.XMLReader; + +/** + * + * @author Ing. František Kučera (frantovo.cz) + */ +public class AltSAXParser extends SAXParser { + + private final XMLReader xmlReader; + + public AltSAXParser(XMLReader xmlReader) { + this.xmlReader = xmlReader; + } + + @Override + @Deprecated + public Parser getParser() throws SAXException { + throw new SAXException("Není podporováno."); + } + + @Override + public XMLReader getXMLReader() throws SAXException { + return xmlReader; + } + + @Override + public boolean isNamespaceAware() { + return true; + } + + @Override + public boolean isValidating() { + return false; + } + + @Override + public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { + xmlReader.setProperty(name, value); + } + + @Override + public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { + return xmlReader.getProperty(name); + } +} diff -r ad36a104623f -r 03f940508c72 java/alt2xml-lib-input/src/cz/frantovo/alt2xml/ParserFactory.java --- a/java/alt2xml-lib-input/src/cz/frantovo/alt2xml/ParserFactory.java Sun Jun 08 09:53:51 2014 +0200 +++ b/java/alt2xml-lib-input/src/cz/frantovo/alt2xml/ParserFactory.java Sun Jun 08 09:57:33 2014 +0200 @@ -24,7 +24,6 @@ import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; -import org.xml.sax.Parser; import org.xml.sax.SAXException; import org.xml.sax.SAXNotRecognizedException; import org.xml.sax.SAXNotSupportedException; @@ -116,11 +115,11 @@ return new AltSAXParser(new SuperReader(this)); } - /** - * TODO: feature for disabling default SAXParserFactory - */ @Override public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { + /** + * TODO: feature for disabling default SAXParserFactory + */ throw new SAXNotSupportedException("Zatím není podporováno."); } @@ -128,44 +127,4 @@ public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { throw new SAXNotSupportedException("Zatím není podporováno."); } - - private static class AltSAXParser extends SAXParser { - - private final XMLReader xmlReader; - - public AltSAXParser(XMLReader xmlReader) { - this.xmlReader = xmlReader; - } - - @Override - @Deprecated - public Parser getParser() throws SAXException { - throw new SAXException("Není podporováno."); - } - - @Override - public XMLReader getXMLReader() throws SAXException { - return xmlReader; - } - - @Override - public boolean isNamespaceAware() { - return true; - } - - @Override - public boolean isValidating() { - return false; - } - - @Override - public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { - xmlReader.setProperty(name, value); - } - - @Override - public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { - return xmlReader.getProperty(name); - } - } }