java/alt2xml/src/cz/frantovo/alt2xml/vstup/SuperReader.java
changeset 4 e2b2f34cdb50
parent 3 6c608fd8c019
child 5 c2496cf043c3
     1.1 --- a/java/alt2xml/src/cz/frantovo/alt2xml/vstup/SuperReader.java	Tue Jan 03 12:55:38 2012 +0100
     1.2 +++ b/java/alt2xml/src/cz/frantovo/alt2xml/vstup/SuperReader.java	Tue Jan 03 14:39:16 2012 +0100
     1.3 @@ -2,8 +2,8 @@
     1.4  
     1.5  import java.io.IOException;
     1.6  import java.io.InputStreamReader;
     1.7 -import java.util.logging.Level;
     1.8 -import java.util.logging.Logger;
     1.9 +import java.util.HashMap;
    1.10 +import java.util.Map;
    1.11  import org.json.simple.parser.JSONParser;
    1.12  import org.json.simple.parser.ParseException;
    1.13  import org.xml.sax.ContentHandler;
    1.14 @@ -22,84 +22,70 @@
    1.15   */
    1.16  public class SuperReader implements XMLReader {
    1.17  
    1.18 -	private static final Logger log = Logger.getLogger(SuperReader.class.getName());
    1.19  	private ContentHandler contentHandler;
    1.20 +	private ErrorHandler errorHandler;
    1.21 +	private DTDHandler dtdHandler;
    1.22 +	private EntityResolver entityResolver;
    1.23 +	private Map<String, Object> konfigurace = new HashMap<>();
    1.24  
    1.25  	@Override
    1.26  	public boolean getFeature(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
    1.27 -		// TODO: dopsat
    1.28 -		log.log(Level.FINE, "getFeature: {0}", name);
    1.29 -		return false;
    1.30 +		throw new SAXNotSupportedException("Zatím není podporováno.");
    1.31  	}
    1.32  
    1.33  	@Override
    1.34  	public void setFeature(String name, boolean value) throws SAXNotRecognizedException, SAXNotSupportedException {
    1.35 -		// TODO: dopsat
    1.36 -		log.log(Level.FINE, "setFeature: {0} = {1}", new Object[]{name, value});
    1.37 +		throw new SAXNotSupportedException("Zatím není podporováno.");
    1.38  	}
    1.39  
    1.40  	@Override
    1.41  	public Object getProperty(String name) throws SAXNotRecognizedException, SAXNotSupportedException {
    1.42 -		// TODO: dopsat
    1.43 -		log.log(Level.FINE, "getProperty: {0}", name);
    1.44 -		return null;
    1.45 +		return konfigurace.get(name);
    1.46  	}
    1.47  
    1.48  	@Override
    1.49  	public void setProperty(String name, Object value) throws SAXNotRecognizedException, SAXNotSupportedException {
    1.50 -		// TODO: dopsat
    1.51 -		log.log(Level.FINE, "setProperty: {0} = {1}", new Object[]{name, value});
    1.52 +		konfigurace.put(name, value);
    1.53  	}
    1.54  
    1.55  	@Override
    1.56 -	public void setEntityResolver(EntityResolver resolver) {
    1.57 -		// TODO: dopsat
    1.58 -		log.log(Level.FINE, "setEntityResolver: {0}", resolver);
    1.59 +	public void setEntityResolver(EntityResolver entityResolver) {
    1.60 +		this.entityResolver = entityResolver;
    1.61  	}
    1.62  
    1.63  	@Override
    1.64  	public EntityResolver getEntityResolver() {
    1.65 -		// TODO: dopsat
    1.66 -		log.log(Level.FINE, "getEntityResolver");
    1.67 -		return null;
    1.68 +		return entityResolver;
    1.69  	}
    1.70  
    1.71  	@Override
    1.72 -	public void setDTDHandler(DTDHandler handler) {
    1.73 -		// TODO: dopsat
    1.74 -		log.log(Level.FINE, "setDTDHandler: {0}", handler);
    1.75 +	public void setDTDHandler(DTDHandler dtdHandler) {
    1.76 +		this.dtdHandler = dtdHandler;
    1.77  	}
    1.78  
    1.79  	@Override
    1.80  	public DTDHandler getDTDHandler() {
    1.81 -		// TODO: dopsat
    1.82 -		log.log(Level.FINE, "getDTDHandler");
    1.83 -		return null;
    1.84 +		return dtdHandler;
    1.85  	}
    1.86  
    1.87  	@Override
    1.88 -	public void setContentHandler(ContentHandler handler) {
    1.89 -		// TODO: dopsat
    1.90 -		contentHandler = handler;
    1.91 +	public void setContentHandler(ContentHandler contentHandler) {
    1.92 +		this.contentHandler = contentHandler;
    1.93  	}
    1.94  
    1.95  	@Override
    1.96  	public ContentHandler getContentHandler() {
    1.97 -		// TODO: dopsat
    1.98  		return contentHandler;
    1.99  	}
   1.100  
   1.101  	@Override
   1.102 -	public void setErrorHandler(ErrorHandler handler) {
   1.103 -		// TODO: dopsat
   1.104 -		log.log(Level.FINE, "setErrorHandler: {0}", handler);
   1.105 +	public void setErrorHandler(ErrorHandler errorHandler) {
   1.106 +		this.errorHandler = errorHandler;
   1.107  	}
   1.108  
   1.109  	@Override
   1.110  	public ErrorHandler getErrorHandler() {
   1.111 -		// TODO: dopsat
   1.112 -		log.log(Level.FINE, "getErrorHandler");
   1.113 -		return null;
   1.114 +		return errorHandler;
   1.115  	}
   1.116  
   1.117  	@Override
   1.118 @@ -107,7 +93,6 @@
   1.119  		/**
   1.120  		 * TODO: rozpornat formát vstupu a podle toho delegovat
   1.121  		 */
   1.122 -		
   1.123  		JSONParser p = new JSONParser();
   1.124  		InputStreamReader vstup = new InputStreamReader(input.getByteStream());
   1.125  		JsonSimpleContentHandler handler = new JsonSimpleContentHandler(contentHandler);
   1.126 @@ -122,6 +107,6 @@
   1.127  	@Override
   1.128  	public void parse(String systemId) throws IOException, SAXException {
   1.129  		// TODO: dopsat
   1.130 -		throw new UnsupportedOperationException("Zatím není podporované.");
   1.131 +		throw new SAXException("Zatím není podporováno.");
   1.132  	}
   1.133  }