1 16 17 package org.apache.xerces.jaxp; 18 19 import java.util.Hashtable ; 20 21 import javax.xml.XMLConstants ; 22 import javax.xml.parsers.ParserConfigurationException ; 23 import javax.xml.parsers.SAXParser ; 24 import javax.xml.parsers.SAXParserFactory ; 25 import javax.xml.validation.Schema ; 26 27 import org.xml.sax.SAXException ; 28 import org.xml.sax.SAXNotRecognizedException ; 29 import org.xml.sax.SAXNotSupportedException ; 30 31 41 public class SAXParserFactoryImpl extends SAXParserFactory { 42 private Hashtable features; 43 private Schema grammar; 44 private boolean isXIncludeAware; 45 46 49 private boolean fSecureProcess = false; 50 51 56 public SAXParser newSAXParser() 57 throws ParserConfigurationException 58 { 59 SAXParser saxParserImpl; 60 try { 61 saxParserImpl = new SAXParserImpl(this, features, fSecureProcess); 62 } catch (SAXException se) { 63 throw new ParserConfigurationException (se.getMessage()); 65 } 66 return saxParserImpl; 67 } 68 69 72 private SAXParserImpl newSAXParserImpl() 73 throws ParserConfigurationException , SAXNotRecognizedException , 74 SAXNotSupportedException 75 { 76 SAXParserImpl saxParserImpl; 77 try { 78 saxParserImpl = new SAXParserImpl(this, features); 79 } catch (SAXNotSupportedException e) { 80 throw e; 81 } catch (SAXNotRecognizedException e) { 82 throw e; 83 } catch (SAXException se) { 84 throw new ParserConfigurationException (se.getMessage()); 85 } 86 return saxParserImpl; 87 } 88 89 93 public void setFeature(String name, boolean value) 94 throws ParserConfigurationException , SAXNotRecognizedException , 95 SAXNotSupportedException { 96 if (name == null) { 97 throw new NullPointerException (); 98 } 99 if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { 101 fSecureProcess = value; 102 return; 103 } 104 105 if (features == null) { 108 features = new Hashtable (); 109 } 110 features.put(name, value ? Boolean.TRUE : Boolean.FALSE); 111 112 try { 114 newSAXParserImpl(); 115 } catch (SAXNotSupportedException e) { 116 features.remove(name); 117 throw e; 118 } catch (SAXNotRecognizedException e) { 119 features.remove(name); 120 throw e; 121 } 122 } 123 124 128 public boolean getFeature(String name) 129 throws ParserConfigurationException , SAXNotRecognizedException , 130 SAXNotSupportedException { 131 if (name == null) { 132 throw new NullPointerException (); 133 } 134 if (name.equals(XMLConstants.FEATURE_SECURE_PROCESSING)) { 135 return fSecureProcess; 136 } 137 return newSAXParserImpl().getXMLReader().getFeature(name); 140 } 141 142 public Schema getSchema() { 143 return grammar; 144 } 145 146 public void setSchema(Schema grammar) { 147 this.grammar = grammar; 148 } 149 150 public boolean isXIncludeAware() { 151 return this.isXIncludeAware; 152 } 153 154 public void setXIncludeAware(boolean state) { 155 this.isXIncludeAware = state; 156 } 157 } 158 | Popular Tags |