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
     1 package cz.frantovo.alt2xml;
     2 
     3 import cz.frantovo.alt2xml.vstup.SuperReader;
     4 import javax.xml.parsers.ParserConfigurationException;
     5 import javax.xml.parsers.SAXParser;
     6 import javax.xml.parsers.SAXParserFactory;
     7 import org.xml.sax.Parser;
     8 import org.xml.sax.SAXException;
     9 import org.xml.sax.SAXNotRecognizedException;
    10 import org.xml.sax.SAXNotSupportedException;
    11 import org.xml.sax.XMLReader;
    12 
    13 /**
    14  *
    15  * @author fiki
    16  */
    17 public class SAXTovarna extends SAXParserFactory {
    18 
    19 	@Override
    20 	public SAXParser newSAXParser() throws ParserConfigurationException, SAXException {
    21 		return new MůjParser(new SuperReader());
    22 	}
    23 
    24 	@Override
    25 	public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
    26 		throw new SAXNotSupportedException("Zatím není podporováno.");
    27 	}
    28 
    29 	@Override
    30 	public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException {
    31 		throw new SAXNotSupportedException("Zatím není podporováno.");
    32 	}
    33 
    34 	private static class MůjParser extends SAXParser {
    35 
    36 		private XMLReader xmlReader;
    37 
    38 		public MůjParser(XMLReader xmlReader) {
    39 			this.xmlReader = xmlReader;
    40 		}
    41 
    42 		@Override
    43 		public Parser getParser() throws SAXException {
    44 			throw new SAXException("Není podporováno.");
    45 		}
    46 
    47 		@Override
    48 		public XMLReader getXMLReader() throws SAXException {
    49 			return xmlReader;
    50 		}
    51 
    52 		@Override
    53 		public boolean isNamespaceAware() {
    54 			return false;
    55 		}
    56 
    57 		@Override
    58 		public boolean isValidating() {
    59 			return false;
    60 		}
    61 
    62 		@Override
    63 		public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
    64 			xmlReader.setProperty(name, value);
    65 		}
    66 
    67 		@Override
    68 		public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
    69 			return xmlReader.getProperty(name);
    70 		}
    71 	}
    72 }