diff -r 5cfb685d8eec -r 9107f7df660c java/alt2xml/src/cz/frantovo/alt2xml/vstup/SuperReader.java --- a/java/alt2xml/src/cz/frantovo/alt2xml/vstup/SuperReader.java Tue Jan 03 14:47:22 2012 +0100 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,111 +0,0 @@ -package cz.frantovo.alt2xml.vstup; - -import java.io.IOException; -import java.io.InputStreamReader; -import java.util.HashMap; -import java.util.Map; -import org.json.simple.parser.JSONParser; -import org.json.simple.parser.ParseException; -import org.xml.sax.ContentHandler; -import org.xml.sax.DTDHandler; -import org.xml.sax.EntityResolver; -import org.xml.sax.ErrorHandler; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.SAXNotRecognizedException; -import org.xml.sax.SAXNotSupportedException; -import org.xml.sax.XMLReader; - -/** - * - * @author fiki - */ -public class SuperReader implements XMLReader { - - private ContentHandler contentHandler; - private ErrorHandler errorHandler; - private DTDHandler dtdHandler; - private EntityResolver entityResolver; - private Map konfigurace = new HashMap<>(); - - @Override - public void parse(InputSource input) throws IOException, SAXException { - /** - * TODO: rozpornat formát vstupu a podle toho delegovat - */ - JSONParser p = new JSONParser(); - InputStreamReader vstup = new InputStreamReader(input.getByteStream()); - JsonSimpleContentHandler handler = new JsonSimpleContentHandler(contentHandler); - - try { - p.parse(vstup, handler); - } catch (ParseException e) { - throw new SAXException("Chyba při načítání JSONu", e); - } - } - - @Override - public void parse(String systemId) throws IOException, SAXException { - parse(new InputSource(systemId)); - } - - @Override - public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException { - throw new SAXNotSupportedException("Zatím není podporováno."); - } - - @Override - public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException { - throw new SAXNotSupportedException("Zatím není podporováno."); - } - - @Override - public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { - return konfigurace.get(name); - } - - @Override - public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { - konfigurace.put(name, value); - } - - @Override - public void setEntityResolver(EntityResolver entityResolver) { - this.entityResolver = entityResolver; - } - - @Override - public EntityResolver getEntityResolver() { - return entityResolver; - } - - @Override - public void setDTDHandler(DTDHandler dtdHandler) { - this.dtdHandler = dtdHandler; - } - - @Override - public DTDHandler getDTDHandler() { - return dtdHandler; - } - - @Override - public void setContentHandler(ContentHandler contentHandler) { - this.contentHandler = contentHandler; - } - - @Override - public ContentHandler getContentHandler() { - return contentHandler; - } - - @Override - public void setErrorHandler(ErrorHandler errorHandler) { - this.errorHandler = errorHandler; - } - - @Override - public ErrorHandler getErrorHandler() { - return errorHandler; - } -}