franta-hg@2: package cz.frantovo.alt2xml; franta-hg@2: franta-hg@3: import cz.frantovo.alt2xml.vstup.SuperReader; franta-hg@2: import javax.xml.parsers.ParserConfigurationException; franta-hg@2: import javax.xml.parsers.SAXParser; franta-hg@2: import javax.xml.parsers.SAXParserFactory; franta-hg@3: import org.xml.sax.Parser; franta-hg@2: import org.xml.sax.SAXException; franta-hg@2: import org.xml.sax.SAXNotRecognizedException; franta-hg@2: import org.xml.sax.SAXNotSupportedException; franta-hg@3: import org.xml.sax.XMLReader; franta-hg@2: franta-hg@2: /** franta-hg@2: * franta-hg@2: * @author fiki franta-hg@2: */ franta-hg@2: public class SAXTovarna extends SAXParserFactory { franta-hg@2: franta-hg@2: @Override franta-hg@2: public SAXParser newSAXParser() throws ParserConfigurationException, SAXException { franta-hg@3: return new MůjParser(new SuperReader()); franta-hg@2: } franta-hg@2: franta-hg@2: @Override franta-hg@2: public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { franta-hg@4: throw new SAXNotSupportedException("Zatím není podporováno."); franta-hg@2: } franta-hg@2: franta-hg@2: @Override franta-hg@2: public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { franta-hg@4: throw new SAXNotSupportedException("Zatím není podporováno."); franta-hg@2: } franta-hg@3: franta-hg@3: private static class MůjParser extends SAXParser { franta-hg@3: franta-hg@3: private XMLReader xmlReader; franta-hg@3: franta-hg@3: public MůjParser(XMLReader xmlReader) { franta-hg@3: this.xmlReader = xmlReader; franta-hg@3: } franta-hg@3: franta-hg@3: @Override franta-hg@3: public Parser getParser() throws SAXException { franta-hg@4: throw new SAXException("Není podporováno."); franta-hg@3: } franta-hg@3: franta-hg@3: @Override franta-hg@3: public XMLReader getXMLReader() throws SAXException { franta-hg@3: return xmlReader; franta-hg@3: } franta-hg@3: franta-hg@3: @Override franta-hg@3: public boolean isNamespaceAware() { franta-hg@3: return false; franta-hg@3: } franta-hg@3: franta-hg@3: @Override franta-hg@3: public boolean isValidating() { franta-hg@3: return false; franta-hg@3: } franta-hg@3: franta-hg@3: @Override franta-hg@3: public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { franta-hg@4: xmlReader.setProperty(name, value); franta-hg@3: } franta-hg@3: franta-hg@3: @Override franta-hg@3: public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { franta-hg@4: return xmlReader.getProperty(name); franta-hg@3: } franta-hg@3: } franta-hg@3: }