1 57 58 59 package com.sun.org.apache.xerces.internal.jaxp; 60 61 import java.util.Hashtable ; 62 63 import javax.xml.XMLConstants ; 64 import javax.xml.parsers.ParserConfigurationException ; 65 import javax.xml.parsers.SAXParser ; 66 import javax.xml.parsers.SAXParserFactory ; 67 import javax.xml.validation.Schema ; 68 69 import org.xml.sax.SAXException ; 70 import org.xml.sax.SAXNotRecognizedException ; 71 import org.xml.sax.SAXNotSupportedException ; 72 77 78 83 public class SAXParserFactoryImpl extends SAXParserFactory { 84 private Hashtable features; 85 private Schema grammar; 86 private boolean isXIncludeAware; 87 88 93 public SAXParser newSAXParser() 94 throws ParserConfigurationException 95 { 96 SAXParser saxParserImpl; 97 try { 98 saxParserImpl = new SAXParserImpl(this, features); 99 } catch (SAXException se) { 100 throw new ParserConfigurationException (se.getMessage()); 102 } 103 return saxParserImpl; 104 } 105 106 109 private SAXParserImpl newSAXParserImpl() 110 throws ParserConfigurationException , SAXNotRecognizedException , 111 SAXNotSupportedException 112 { 113 SAXParserImpl saxParserImpl; 114 try { 115 saxParserImpl = new SAXParserImpl(this, features); 116 } catch (SAXNotSupportedException e) { 117 throw e; 118 } catch (SAXNotRecognizedException e) { 119 throw e; 120 } catch (SAXException se) { 121 throw new ParserConfigurationException (se.getMessage()); 122 } 123 return saxParserImpl; 124 } 125 126 130 public void setFeature(String name, boolean value) 131 throws ParserConfigurationException , SAXNotRecognizedException , 132 SAXNotSupportedException 133 { 134 if (features == null) { 137 features = new Hashtable (); 138 } 139 features.put(name, value ? Boolean.TRUE : Boolean.FALSE); 140 141 try { 143 newSAXParserImpl(); 144 } catch (SAXNotSupportedException e) { 145 features.remove(name); 146 throw e; 147 } catch (SAXNotRecognizedException e) { 148 features.remove(name); 149 throw e; 150 } 151 } 152 153 157 public boolean getFeature(String name) 158 throws ParserConfigurationException , SAXNotRecognizedException , 159 SAXNotSupportedException 160 { 161 if(name.equals(XMLConstants.FEATURE_SECURE_PROCESSING) && features != null){ 164 Boolean ob =(Boolean ) features.get(name); 165 if(ob == null ) 166 return false; 167 return ob.booleanValue(); 168 } 169 return newSAXParserImpl().getXMLReader().getFeature(name); 170 } 171 172 public Schema getSchema() { 173 return grammar; 174 } 175 176 public void setSchema(Schema grammar) { 177 this.grammar = grammar; 178 } 179 180 181 public boolean isXIncludeAware() { 182 return this.isXIncludeAware; 183 } 184 185 public void setXIncludeAware(boolean state) { 186 this.isXIncludeAware = state; 187 } 188 } 189 | Popular Tags |