001    package com.thaiopensource.validate.schematron;
002    
003    import org.xml.sax.XMLReader;
004    import org.xml.sax.SAXException;
005    import org.xml.sax.InputSource;
006    import org.xml.sax.ErrorHandler;
007    import org.xml.sax.DTDHandler;
008    import org.xml.sax.EntityResolver;
009    import org.xml.sax.SAXNotRecognizedException;
010    import org.xml.sax.SAXNotSupportedException;
011    
012    import java.io.IOException;
013    
014    abstract class XMLReaderImpl implements XMLReader {
015      private ErrorHandler errorHandler;
016      private DTDHandler dtdHandler;
017      private EntityResolver entityResolver;
018    
019      public void parse(String systemId)
020              throws SAXException, IOException {
021        parse(new InputSource(systemId));
022      }
023    
024    
025      public ErrorHandler getErrorHandler() {
026        return errorHandler;
027      }
028    
029      public void setErrorHandler(ErrorHandler errorHandler) {
030        this.errorHandler = errorHandler;
031      }
032    
033      public void setDTDHandler(DTDHandler handler) {
034        this.dtdHandler = handler;
035      }
036    
037      public DTDHandler getDTDHandler() {
038        return dtdHandler;
039      }
040    
041      public void setEntityResolver(EntityResolver resolver) {
042        this.entityResolver = resolver;
043      }
044    
045      public EntityResolver getEntityResolver() {
046        return entityResolver;
047      }
048    
049      public Object getProperty(String name)
050              throws SAXNotRecognizedException, SAXNotSupportedException {
051        throw new SAXNotRecognizedException(name);
052      }
053    
054      public void setProperty(String name, Object value)
055              throws SAXNotRecognizedException, SAXNotSupportedException {
056        throw new SAXNotRecognizedException(name);
057      }
058    
059      public boolean getFeature(String name)
060              throws SAXNotRecognizedException, SAXNotSupportedException {
061        if (name.equals("http://xml.org/sax/features/namespaces"))
062          return true;
063        if (name.equals("http://xml.org/sax/features/namespace-prefixes"))
064          return false;
065        throw new SAXNotRecognizedException(name);
066      }
067    
068      public void setFeature(String name, boolean value)
069              throws SAXNotRecognizedException, SAXNotSupportedException {
070        if (name.equals("http://xml.org/sax/features/namespaces")) {
071          if (value == true)
072            return;
073          throw new SAXNotSupportedException(name);
074        }
075        if (name.equals("http://xml.org/sax/features/namespace-prefixes")) {
076          if (value == false)
077            return;
078          throw new SAXNotSupportedException(name);
079        }
080        throw new SAXNotRecognizedException(name);
081      }
082    }