java/alt2xml-bin/src/cz/frantovo/alt2xml/SAXTovarna.java
author František Kučera <franta-hg@frantovo.cz>
Thu, 05 Jun 2014 22:01:58 +0200
changeset 11 aaf6648af0aa
parent 7 9107f7df660c
child 15 b890783e4043
permissions -rw-r--r--
licence
franta-hg@11
     1
/**
franta-hg@11
     2
 * Alt2XML
franta-hg@11
     3
 * Copyright © 2014 František Kučera (frantovo.cz)
franta-hg@11
     4
 *
franta-hg@11
     5
 * This program is free software: you can redistribute it and/or modify
franta-hg@11
     6
 * it under the terms of the GNU General Public License as published by
franta-hg@11
     7
 * the Free Software Foundation, either version 3 of the License, or
franta-hg@11
     8
 * (at your option) any later version.
franta-hg@11
     9
 *
franta-hg@11
    10
 * This program is distributed in the hope that it will be useful,
franta-hg@11
    11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
franta-hg@11
    12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
franta-hg@11
    13
 * GNU General Public License for more details.
franta-hg@11
    14
 *
franta-hg@11
    15
 * You should have received a copy of the GNU General Public License
franta-hg@11
    16
 * along with this program. If not, see <http://www.gnu.org/licenses/>.
franta-hg@11
    17
 */
franta-hg@2
    18
package cz.frantovo.alt2xml;
franta-hg@2
    19
franta-hg@3
    20
import cz.frantovo.alt2xml.vstup.SuperReader;
franta-hg@2
    21
import javax.xml.parsers.ParserConfigurationException;
franta-hg@2
    22
import javax.xml.parsers.SAXParser;
franta-hg@2
    23
import javax.xml.parsers.SAXParserFactory;
franta-hg@3
    24
import org.xml.sax.Parser;
franta-hg@2
    25
import org.xml.sax.SAXException;
franta-hg@2
    26
import org.xml.sax.SAXNotRecognizedException;
franta-hg@2
    27
import org.xml.sax.SAXNotSupportedException;
franta-hg@3
    28
import org.xml.sax.XMLReader;
franta-hg@2
    29
franta-hg@2
    30
/**
franta-hg@2
    31
 *
franta-hg@2
    32
 * @author fiki
franta-hg@2
    33
 */
franta-hg@2
    34
public class SAXTovarna extends SAXParserFactory {
franta-hg@2
    35
franta-hg@2
    36
	@Override
franta-hg@2
    37
	public SAXParser newSAXParser() throws ParserConfigurationException, SAXException {
franta-hg@11
    38
		return new AltSAXParser(new SuperReader());
franta-hg@2
    39
	}
franta-hg@2
    40
franta-hg@2
    41
	@Override
franta-hg@2
    42
	public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
franta-hg@4
    43
		throw new SAXNotSupportedException("Zatím není podporováno.");
franta-hg@2
    44
	}
franta-hg@2
    45
franta-hg@2
    46
	@Override
franta-hg@2
    47
	public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
franta-hg@4
    48
		throw new SAXNotSupportedException("Zatím není podporováno.");
franta-hg@2
    49
	}
franta-hg@3
    50
franta-hg@11
    51
	private static class AltSAXParser extends SAXParser {
franta-hg@3
    52
franta-hg@3
    53
		private XMLReader xmlReader;
franta-hg@3
    54
franta-hg@11
    55
		public AltSAXParser(XMLReader xmlReader) {
franta-hg@3
    56
			this.xmlReader = xmlReader;
franta-hg@3
    57
		}
franta-hg@3
    58
franta-hg@3
    59
		@Override
franta-hg@11
    60
		@Deprecated
franta-hg@3
    61
		public Parser getParser() throws SAXException {
franta-hg@4
    62
			throw new SAXException("Není podporováno.");
franta-hg@3
    63
		}
franta-hg@3
    64
franta-hg@3
    65
		@Override
franta-hg@3
    66
		public XMLReader getXMLReader() throws SAXException {
franta-hg@3
    67
			return xmlReader;
franta-hg@3
    68
		}
franta-hg@3
    69
franta-hg@3
    70
		@Override
franta-hg@3
    71
		public boolean isNamespaceAware() {
franta-hg@11
    72
			return true;
franta-hg@3
    73
		}
franta-hg@3
    74
franta-hg@3
    75
		@Override
franta-hg@3
    76
		public boolean isValidating() {
franta-hg@3
    77
			return false;
franta-hg@3
    78
		}
franta-hg@3
    79
franta-hg@3
    80
		@Override
franta-hg@3
    81
		public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
franta-hg@4
    82
			xmlReader.setProperty(name, value);
franta-hg@3
    83
		}
franta-hg@3
    84
franta-hg@3
    85
		@Override
franta-hg@3
    86
		public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
franta-hg@4
    87
			return xmlReader.getProperty(name);
franta-hg@3
    88
		}
franta-hg@3
    89
	}
franta-hg@3
    90
}