3 * Copyright © 2014 František Kučera (frantovo.cz)
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 package cz.frantovo.alt2xml;
20 import java.io.IOException;
21 import java.util.HashMap;
23 import org.xml.sax.ContentHandler;
24 import org.xml.sax.DTDHandler;
25 import org.xml.sax.EntityResolver;
26 import org.xml.sax.ErrorHandler;
27 import org.xml.sax.InputSource;
28 import org.xml.sax.SAXException;
29 import org.xml.sax.SAXNotRecognizedException;
30 import org.xml.sax.SAXNotSupportedException;
31 import org.xml.sax.XMLReader;
34 * Recommended base class for all alternative format readers.
36 * @author Ing. František Kučera (frantovo.cz)
38 public abstract class AbstractAlt2XmlReader implements XMLReader {
40 protected ContentHandler contentHandler;
41 protected ErrorHandler errorHandler;
42 protected DTDHandler dtdHandler;
43 protected EntityResolver entityResolver;
44 protected Map<String, Object> properties = new HashMap<>();
47 public void parse(String systemId) throws IOException, SAXException {
48 parse(new InputSource(systemId));
52 public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
55 * All XMLReaders are required to recognize
56 * the http://xml.org/sax/features/namespaces
57 * and the http://xml.org/sax/features/namespace-prefixes feature names.
59 throw new SAXNotSupportedException("Zatím není podporováno.");
63 public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
64 throw new SAXNotSupportedException("Zatím není podporováno.");
68 public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
69 return properties.get(name);
73 public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
74 properties.put(name, value);
78 public void setEntityResolver(EntityResolver entityResolver) {
79 this.entityResolver = entityResolver;
83 public EntityResolver getEntityResolver() {
84 return entityResolver;
88 public void setDTDHandler(DTDHandler dtdHandler) {
89 this.dtdHandler = dtdHandler;
93 public DTDHandler getDTDHandler() {
98 public void setContentHandler(ContentHandler contentHandler) {
99 this.contentHandler = contentHandler;
103 public ContentHandler getContentHandler() {
104 return contentHandler;
108 public void setErrorHandler(ErrorHandler errorHandler) {
109 this.errorHandler = errorHandler;
113 public ErrorHandler getErrorHandler() {