java/alt2xml-bin/src/cz/frantovo/alt2xml/SAXTovarna.java
author František Kučera <franta-hg@frantovo.cz>
Thu, 05 Jun 2014 10:07:34 +0200
changeset 7 9107f7df660c
parent 4 java/alt2xml/src/cz/frantovo/alt2xml/SAXTovarna.java@e2b2f34cdb50
child 11 aaf6648af0aa
permissions -rw-r--r--
přejmenování alt2xml → alt2xml-bin
franta-hg@2
     1
package cz.frantovo.alt2xml;
franta-hg@2
     2
franta-hg@3
     3
import cz.frantovo.alt2xml.vstup.SuperReader;
franta-hg@2
     4
import javax.xml.parsers.ParserConfigurationException;
franta-hg@2
     5
import javax.xml.parsers.SAXParser;
franta-hg@2
     6
import javax.xml.parsers.SAXParserFactory;
franta-hg@3
     7
import org.xml.sax.Parser;
franta-hg@2
     8
import org.xml.sax.SAXException;
franta-hg@2
     9
import org.xml.sax.SAXNotRecognizedException;
franta-hg@2
    10
import org.xml.sax.SAXNotSupportedException;
franta-hg@3
    11
import org.xml.sax.XMLReader;
franta-hg@2
    12
franta-hg@2
    13
/**
franta-hg@2
    14
 *
franta-hg@2
    15
 * @author fiki
franta-hg@2
    16
 */
franta-hg@2
    17
public class SAXTovarna extends SAXParserFactory {
franta-hg@2
    18
franta-hg@2
    19
	@Override
franta-hg@2
    20
	public SAXParser newSAXParser() throws ParserConfigurationException, SAXException {
franta-hg@3
    21
		return new MůjParser(new SuperReader());
franta-hg@2
    22
	}
franta-hg@2
    23
franta-hg@2
    24
	@Override
franta-hg@2
    25
	public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
franta-hg@4
    26
		throw new SAXNotSupportedException("Zatím není podporováno.");
franta-hg@2
    27
	}
franta-hg@2
    28
franta-hg@2
    29
	@Override
franta-hg@2
    30
	public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
franta-hg@4
    31
		throw new SAXNotSupportedException("Zatím není podporováno.");
franta-hg@2
    32
	}
franta-hg@3
    33
franta-hg@3
    34
	private static class MůjParser extends SAXParser {
franta-hg@3
    35
franta-hg@3
    36
		private XMLReader xmlReader;
franta-hg@3
    37
franta-hg@3
    38
		public MůjParser(XMLReader xmlReader) {
franta-hg@3
    39
			this.xmlReader = xmlReader;
franta-hg@3
    40
		}
franta-hg@3
    41
franta-hg@3
    42
		@Override
franta-hg@3
    43
		public Parser getParser() throws SAXException {
franta-hg@4
    44
			throw new SAXException("Není podporováno.");
franta-hg@3
    45
		}
franta-hg@3
    46
franta-hg@3
    47
		@Override
franta-hg@3
    48
		public XMLReader getXMLReader() throws SAXException {
franta-hg@3
    49
			return xmlReader;
franta-hg@3
    50
		}
franta-hg@3
    51
franta-hg@3
    52
		@Override
franta-hg@3
    53
		public boolean isNamespaceAware() {
franta-hg@3
    54
			return false;
franta-hg@3
    55
		}
franta-hg@3
    56
franta-hg@3
    57
		@Override
franta-hg@3
    58
		public boolean isValidating() {
franta-hg@3
    59
			return false;
franta-hg@3
    60
		}
franta-hg@3
    61
franta-hg@3
    62
		@Override
franta-hg@3
    63
		public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
franta-hg@4
    64
			xmlReader.setProperty(name, value);
franta-hg@3
    65
		}
franta-hg@3
    66
franta-hg@3
    67
		@Override
franta-hg@3
    68
		public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
franta-hg@4
    69
			return xmlReader.getProperty(name);
franta-hg@3
    70
		}
franta-hg@3
    71
	}
franta-hg@3
    72
}