1 package com.thaiopensource.validate.schematron; 2 3 import org.xml.sax.XMLReader ; 4 import org.xml.sax.SAXException ; 5 import org.xml.sax.InputSource ; 6 import org.xml.sax.ErrorHandler ; 7 import org.xml.sax.DTDHandler ; 8 import org.xml.sax.EntityResolver ; 9 import org.xml.sax.SAXNotRecognizedException ; 10 import org.xml.sax.SAXNotSupportedException ; 11 12 import java.io.IOException ; 13 14 abstract class XMLReaderImpl implements XMLReader { 15 private ErrorHandler errorHandler; 16 private DTDHandler dtdHandler; 17 private EntityResolver entityResolver; 18 19 public void parse(String systemId) 20 throws SAXException , IOException { 21 parse(new InputSource (systemId)); 22 } 23 24 25 public ErrorHandler getErrorHandler() { 26 return errorHandler; 27 } 28 29 public void setErrorHandler(ErrorHandler errorHandler) { 30 this.errorHandler = errorHandler; 31 } 32 33 public void setDTDHandler(DTDHandler handler) { 34 this.dtdHandler = handler; 35 } 36 37 public DTDHandler getDTDHandler() { 38 return dtdHandler; 39 } 40 41 public void setEntityResolver(EntityResolver resolver) { 42 this.entityResolver = resolver; 43 } 44 45 public EntityResolver getEntityResolver() { 46 return entityResolver; 47 } 48 49 public Object getProperty(String name) 50 throws SAXNotRecognizedException , SAXNotSupportedException { 51 throw new SAXNotRecognizedException (name); 52 } 53 54 public void setProperty(String name, Object value) 55 throws SAXNotRecognizedException , SAXNotSupportedException { 56 throw new SAXNotRecognizedException (name); 57 } 58 59 public boolean getFeature(String name) 60 throws SAXNotRecognizedException , SAXNotSupportedException { 61 if (name.equals("http://xml.org/sax/features/namespaces")) 62 return true; 63 if (name.equals("http://xml.org/sax/features/namespace-prefixes")) 64 return false; 65 throw new SAXNotRecognizedException (name); 66 } 67 68 public void setFeature(String name, boolean value) 69 throws SAXNotRecognizedException , SAXNotSupportedException { 70 if (name.equals("http://xml.org/sax/features/namespaces")) { 71 if (value == true) 72 return; 73 throw new SAXNotSupportedException (name); 74 } 75 if (name.equals("http://xml.org/sax/features/namespace-prefixes")) { 76 if (value == false) 77 return; 78 throw new SAXNotSupportedException (name); 79 } 80 throw new SAXNotRecognizedException (name); 81 } 82 } 83 | Popular Tags |