1.1 --- a/java/alt2xml/src/cz/frantovo/alt2xml/vstup/SuperReader.java Tue Jan 03 14:47:22 2012 +0100
1.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000
1.3 @@ -1,111 +0,0 @@
1.4 -package cz.frantovo.alt2xml.vstup;
1.5 -
1.6 -import java.io.IOException;
1.7 -import java.io.InputStreamReader;
1.8 -import java.util.HashMap;
1.9 -import java.util.Map;
1.10 -import org.json.simple.parser.JSONParser;
1.11 -import org.json.simple.parser.ParseException;
1.12 -import org.xml.sax.ContentHandler;
1.13 -import org.xml.sax.DTDHandler;
1.14 -import org.xml.sax.EntityResolver;
1.15 -import org.xml.sax.ErrorHandler;
1.16 -import org.xml.sax.InputSource;
1.17 -import org.xml.sax.SAXException;
1.18 -import org.xml.sax.SAXNotRecognizedException;
1.19 -import org.xml.sax.SAXNotSupportedException;
1.20 -import org.xml.sax.XMLReader;
1.21 -
1.22 -/**
1.23 - *
1.24 - * @author fiki
1.25 - */
1.26 -public class SuperReader implements XMLReader {
1.27 -
1.28 - private ContentHandler contentHandler;
1.29 - private ErrorHandler errorHandler;
1.30 - private DTDHandler dtdHandler;
1.31 - private EntityResolver entityResolver;
1.32 - private Map<String, Object> konfigurace = new HashMap<>();
1.33 -
1.34 - @Override
1.35 - public void parse(InputSource input) throws IOException, SAXException {
1.36 - /**
1.37 - * TODO: rozpornat formát vstupu a podle toho delegovat
1.38 - */
1.39 - JSONParser p = new JSONParser();
1.40 - InputStreamReader vstup = new InputStreamReader(input.getByteStream());
1.41 - JsonSimpleContentHandler handler = new JsonSimpleContentHandler(contentHandler);
1.42 -
1.43 - try {
1.44 - p.parse(vstup, handler);
1.45 - } catch (ParseException e) {
1.46 - throw new SAXException("Chyba při načítání JSONu", e);
1.47 - }
1.48 - }
1.49 -
1.50 - @Override
1.51 - public void parse(String systemId) throws IOException, SAXException {
1.52 - parse(new InputSource(systemId));
1.53 - }
1.54 -
1.55 - @Override
1.56 - public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
1.57 - throw new SAXNotSupportedException("Zatím není podporováno.");
1.58 - }
1.59 -
1.60 - @Override
1.61 - public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
1.62 - throw new SAXNotSupportedException("Zatím není podporováno.");
1.63 - }
1.64 -
1.65 - @Override
1.66 - public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
1.67 - return konfigurace.get(name);
1.68 - }
1.69 -
1.70 - @Override
1.71 - public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
1.72 - konfigurace.put(name, value);
1.73 - }
1.74 -
1.75 - @Override
1.76 - public void setEntityResolver(EntityResolver entityResolver) {
1.77 - this.entityResolver = entityResolver;
1.78 - }
1.79 -
1.80 - @Override
1.81 - public EntityResolver getEntityResolver() {
1.82 - return entityResolver;
1.83 - }
1.84 -
1.85 - @Override
1.86 - public void setDTDHandler(DTDHandler dtdHandler) {
1.87 - this.dtdHandler = dtdHandler;
1.88 - }
1.89 -
1.90 - @Override
1.91 - public DTDHandler getDTDHandler() {
1.92 - return dtdHandler;
1.93 - }
1.94 -
1.95 - @Override
1.96 - public void setContentHandler(ContentHandler contentHandler) {
1.97 - this.contentHandler = contentHandler;
1.98 - }
1.99 -
1.100 - @Override
1.101 - public ContentHandler getContentHandler() {
1.102 - return contentHandler;
1.103 - }
1.104 -
1.105 - @Override
1.106 - public void setErrorHandler(ErrorHandler errorHandler) {
1.107 - this.errorHandler = errorHandler;
1.108 - }
1.109 -
1.110 - @Override
1.111 - public ErrorHandler getErrorHandler() {
1.112 - return errorHandler;
1.113 - }
1.114 -}