# HG changeset patch # User František Kučera # Date 1325597956 -3600 # Node ID e2b2f34cdb50445f4a527a2e3b1319fde3f263cd # Parent 6c608fd8c0192e0c03018b13730b74735b0b2e27 Podpora konfigurace. diff -r 6c608fd8c019 -r e2b2f34cdb50 java/alt2xml/src/cz/frantovo/alt2xml/SAXTovarna.java --- a/java/alt2xml/src/cz/frantovo/alt2xml/SAXTovarna.java Tue Jan 03 12:55:38 2012 +0100 +++ b/java/alt2xml/src/cz/frantovo/alt2xml/SAXTovarna.java Tue Jan 03 14:39:16 2012 +0100 @@ -1,8 +1,6 @@ package cz.frantovo.alt2xml; import cz.frantovo.alt2xml.vstup.SuperReader; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; @@ -25,17 +23,16 @@ @Override public void setFeature(String name, boolean value) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { - throw new UnsupportedOperationException("Not supported yet."); + throw new SAXNotSupportedException("Zatím není podporováno."); } @Override public boolean getFeature(String name) throws ParserConfigurationException, SAXNotRecognizedException, SAXNotSupportedException { - throw new UnsupportedOperationException("Not supported yet."); + throw new SAXNotSupportedException("Zatím není podporováno."); } private static class MůjParser extends SAXParser { - private static final Logger log = Logger.getLogger(MůjParser.class.getName()); private XMLReader xmlReader; public MůjParser(XMLReader xmlReader) { @@ -44,9 +41,7 @@ @Override public Parser getParser() throws SAXException { - // TODO: dopsat - log.log(Level.FINE, "getParser"); - return null; + throw new SAXException("Není podporováno."); } @Override @@ -56,29 +51,22 @@ @Override public boolean isNamespaceAware() { - // TODO: dopsat - log.log(Level.FINE, "isNamespaceAware"); return false; } @Override public boolean isValidating() { - // TODO: dopsat - log.log(Level.FINE, "isValidating"); return false; } @Override public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { - // TODO: dopsat - log.log(Level.FINE, "setProperty: {0} = {1}", new Object[]{name, value}); + xmlReader.setProperty(name, value); } @Override public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { - // TODO: dopsat - log.log(Level.FINE, "getProperty: {0}", name); - return null; + return xmlReader.getProperty(name); } } } \ No newline at end of file diff -r 6c608fd8c019 -r e2b2f34cdb50 java/alt2xml/src/cz/frantovo/alt2xml/vstup/JsonSimpleContentHandler.java --- a/java/alt2xml/src/cz/frantovo/alt2xml/vstup/JsonSimpleContentHandler.java Tue Jan 03 12:55:38 2012 +0100 +++ b/java/alt2xml/src/cz/frantovo/alt2xml/vstup/JsonSimpleContentHandler.java Tue Jan 03 14:39:16 2012 +0100 @@ -7,7 +7,7 @@ import org.xml.sax.SAXException; /** -) * + * * @author fiki */ public class JsonSimpleContentHandler implements org.json.simple.parser.ContentHandler { diff -r 6c608fd8c019 -r e2b2f34cdb50 java/alt2xml/src/cz/frantovo/alt2xml/vstup/SuperReader.java --- a/java/alt2xml/src/cz/frantovo/alt2xml/vstup/SuperReader.java Tue Jan 03 12:55:38 2012 +0100 +++ b/java/alt2xml/src/cz/frantovo/alt2xml/vstup/SuperReader.java Tue Jan 03 14:39:16 2012 +0100 @@ -2,8 +2,8 @@ import java.io.IOException; import java.io.InputStreamReader; -import java.util.logging.Level; -import java.util.logging.Logger; +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; @@ -22,84 +22,70 @@ */ public class SuperReader implements XMLReader { - private static final Logger log = Logger.getLogger(SuperReader.class.getName()); private ContentHandler contentHandler; + private ErrorHandler errorHandler; + private DTDHandler dtdHandler; + private EntityResolver entityResolver; + private Map konfigurace = new HashMap<>(); @Override public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException { - // TODO: dopsat - log.log(Level.FINE, "getFeature: {0}", name); - return false; + throw new SAXNotSupportedException("Zatím není podporováno."); } @Override public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException { - // TODO: dopsat - log.log(Level.FINE, "setFeature: {0} = {1}", new Object[]{name, value}); + throw new SAXNotSupportedException("Zatím není podporováno."); } @Override public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException { - // TODO: dopsat - log.log(Level.FINE, "getProperty: {0}", name); - return null; + return konfigurace.get(name); } @Override public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException { - // TODO: dopsat - log.log(Level.FINE, "setProperty: {0} = {1}", new Object[]{name, value}); + konfigurace.put(name, value); } @Override - public void setEntityResolver(EntityResolver resolver) { - // TODO: dopsat - log.log(Level.FINE, "setEntityResolver: {0}", resolver); + public void setEntityResolver(EntityResolver entityResolver) { + this.entityResolver = entityResolver; } @Override public EntityResolver getEntityResolver() { - // TODO: dopsat - log.log(Level.FINE, "getEntityResolver"); - return null; + return entityResolver; } @Override - public void setDTDHandler(DTDHandler handler) { - // TODO: dopsat - log.log(Level.FINE, "setDTDHandler: {0}", handler); + public void setDTDHandler(DTDHandler dtdHandler) { + this.dtdHandler = dtdHandler; } @Override public DTDHandler getDTDHandler() { - // TODO: dopsat - log.log(Level.FINE, "getDTDHandler"); - return null; + return dtdHandler; } @Override - public void setContentHandler(ContentHandler handler) { - // TODO: dopsat - contentHandler = handler; + public void setContentHandler(ContentHandler contentHandler) { + this.contentHandler = contentHandler; } @Override public ContentHandler getContentHandler() { - // TODO: dopsat return contentHandler; } @Override - public void setErrorHandler(ErrorHandler handler) { - // TODO: dopsat - log.log(Level.FINE, "setErrorHandler: {0}", handler); + public void setErrorHandler(ErrorHandler errorHandler) { + this.errorHandler = errorHandler; } @Override public ErrorHandler getErrorHandler() { - // TODO: dopsat - log.log(Level.FINE, "getErrorHandler"); - return null; + return errorHandler; } @Override @@ -107,7 +93,6 @@ /** * TODO: rozpornat formát vstupu a podle toho delegovat */ - JSONParser p = new JSONParser(); InputStreamReader vstup = new InputStreamReader(input.getByteStream()); JsonSimpleContentHandler handler = new JsonSimpleContentHandler(contentHandler); @@ -122,6 +107,6 @@ @Override public void parse(String systemId) throws IOException, SAXException { // TODO: dopsat - throw new UnsupportedOperationException("Zatím není podporované."); + throw new SAXException("Zatím není podporováno."); } }