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.in;
20 import org.xml.sax.Attributes;
21 import org.xml.sax.ContentHandler;
22 import org.xml.sax.Locator;
23 import org.xml.sax.SAXException;
26 * Improved wrapper for SAX ContentHandler.
28 * @author Ing. František Kučera (frantovo.cz)
30 public class Alt2ContentHandler implements ContentHandler {
32 private final ContentHandler handler;
34 public Alt2ContentHandler(ContentHandler handler) {
35 this.handler = handler;
38 public void lineBreak() throws SAXException {
39 // TODO: ignorableWhitespace()
43 public void indentation(int level) throws SAXException {
44 for (int i = 0; i < level; i++) {
45 // TODO: ignorableWhitespace()
50 public void characters(String text) throws SAXException {
51 handler.characters(text.toCharArray(), 0, text.length());
54 public void ignorableWhitespace(String text) throws SAXException {
55 handler.ignorableWhitespace(text.toCharArray(), 0, text.length());
58 // ---------------------------------------------------------------------------------------------
60 public void setDocumentLocator(Locator locator) {
61 handler.setDocumentLocator(locator);
65 public void startDocument() throws SAXException {
66 handler.startDocument();
70 public void endDocument() throws SAXException {
71 handler.endDocument();
75 public void startPrefixMapping(String prefix, String uri) throws SAXException {
76 handler.startPrefixMapping(prefix, uri);
80 public void endPrefixMapping(String prefix) throws SAXException {
81 handler.endPrefixMapping(prefix);
85 public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
86 handler.startElement(uri, localName, qName, atts);
90 public void endElement(String uri, String localName, String qName) throws SAXException {
91 handler.endElement(uri, localName, qName);
95 public void characters(char[] ch, int start, int length) throws SAXException {
96 handler.characters(ch, start, length);
100 public void ignorableWhitespace(char[] ch, int start, int length) throws SAXException {
101 handler.ignorableWhitespace(ch, start, length);
105 public void processingInstruction(String target, String data) throws SAXException {
106 handler.processingInstruction(target, data);
110 public void skippedEntity(String name) throws SAXException {
111 handler.skippedEntity(name);