1 58 59 60 package org.enhydra.apache.xerces.jaxp; 61 62 import java.util.Hashtable ; 63 64 import javax.xml.parsers.ParserConfigurationException ; 65 import javax.xml.parsers.SAXParser ; 66 import javax.xml.parsers.SAXParserFactory ; 67 68 import org.xml.sax.SAXException ; 69 import org.xml.sax.SAXNotRecognizedException ; 70 import org.xml.sax.SAXNotSupportedException ; 71 72 77 78 83 public class SAXParserFactoryImpl extends SAXParserFactory { 84 private Hashtable features; 85 86 91 public SAXParser newSAXParser() 92 throws ParserConfigurationException 93 { 94 SAXParser saxParserImpl; 95 try { 96 saxParserImpl = new SAXParserImpl(this, features); 97 } catch (SAXException se) { 98 throw new ParserConfigurationException (se.getMessage()); 100 } 101 return saxParserImpl; 102 } 103 104 107 private SAXParserImpl newSAXParserImpl() 108 throws ParserConfigurationException , SAXNotRecognizedException , 109 SAXNotSupportedException 110 { 111 SAXParserImpl saxParserImpl; 112 try { 113 saxParserImpl = new SAXParserImpl(this, features); 114 } catch (SAXNotSupportedException e) { 115 throw e; 116 } catch (SAXNotRecognizedException e) { 117 throw e; 118 } catch (SAXException se) { 119 throw new ParserConfigurationException (se.getMessage()); 120 } 121 return saxParserImpl; 122 } 123 124 128 public void setFeature(String name, boolean value) 129 throws ParserConfigurationException , SAXNotRecognizedException , 130 SAXNotSupportedException 131 { 132 if (features == null) { 135 features = new Hashtable (); 136 } 137 features.put(name, new Boolean (value)); 138 139 try { 141 newSAXParserImpl(); 142 } catch (SAXNotSupportedException e) { 143 features.remove(name); 144 throw e; 145 } catch (SAXNotRecognizedException e) { 146 features.remove(name); 147 throw e; 148 } 149 } 150 151 155 public boolean getFeature(String name) 156 throws ParserConfigurationException , SAXNotRecognizedException , 157 SAXNotSupportedException 158 { 159 return newSAXParserImpl().getXMLReader().getFeature(name); 162 } 163 } 164 | Popular Tags |