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, version 3 of the License.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 package cz.frantovo.alt2xml.in;
19 import org.xml.sax.Attributes;
20 import org.xml.sax.ContentHandler;
21 import org.xml.sax.Locator;
22 import org.xml.sax.SAXException;
25 * Improved wrapper for SAX ContentHandler.
27 * @author Ing. František Kučera (frantovo.cz)
29 public class Alt2ContentHandler implements ContentHandler {
31 private final ContentHandler handler;
33 public Alt2ContentHandler(ContentHandler handler) {
34 this.handler = handler;
37 public void lineBreak() throws SAXException {
38 // TODO: ignorableWhitespace()
42 public void indentation(int level) throws SAXException {
43 for (int i = 0; i < level; i++) {
44 // TODO: ignorableWhitespace()
49 public void characters(String text) throws SAXException {
50 handler.characters(text.toCharArray(), 0, text.length());
53 public void ignorableWhitespace(String text) throws SAXException {
54 handler.ignorableWhitespace(text.toCharArray(), 0, text.length());
57 public void textElement(String text, String uri, String localName, String qName, Attributes atts) throws SAXException {
58 startElement(uri, localName, qName, atts);
60 endElement(uri, localName, qName);
63 // ---------------------------------------------------------------------------------------------
65 public void setDocumentLocator(Locator locator) {
66 handler.setDocumentLocator(locator);
70 public void startDocument() throws SAXException {
71 handler.startDocument();
75 public void endDocument() throws SAXException {
76 handler.endDocument();
80 public void startPrefixMapping(String prefix, String uri) throws SAXException {
81 handler.startPrefixMapping(prefix, uri);
85 public void endPrefixMapping(String prefix) throws SAXException {
86 handler.endPrefixMapping(prefix);
90 public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
91 handler.startElement(uri, localName, qName, atts);
95 public void endElement(String uri, String localName, String qName) throws SAXException {
96 handler.endElement(uri, localName, qName);
100 public void characters(char[] ch, int start, int length) throws SAXException {
101 handler.characters(ch, start, length);
105 public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
106 handler.ignorableWhitespace(ch, start, length);
110 public void processingInstruction(String target, String data) throws SAXException {
111 handler.processingInstruction(target, data);
115 public void skippedEntity(String name) throws SAXException {
116 handler.skippedEntity(name);