1 58 59 60 package org.enhydra.apache.xerces.jaxp; 61 62 import java.util.Hashtable ; 63 64 import javax.xml.parsers.DocumentBuilder ; 65 import javax.xml.parsers.DocumentBuilderFactory ; 66 import javax.xml.parsers.ParserConfigurationException ; 67 68 import org.enhydra.apache.xerces.parsers.DOMParser; 69 import org.xml.sax.SAXException ; 70 71 76 public class DocumentBuilderFactoryImpl extends DocumentBuilderFactory { 77 78 private Hashtable attributes; 79 80 public DocumentBuilderFactoryImpl() { 81 82 } 83 84 87 public DocumentBuilder newDocumentBuilder() 88 throws ParserConfigurationException 89 { 90 try { 91 return new DocumentBuilderImpl(this, attributes); 92 } catch (SAXException se) { 93 throw new ParserConfigurationException (se.getMessage()); 95 } 96 } 97 98 102 public void setAttribute(String name, Object value) 103 throws IllegalArgumentException 104 { 105 if (attributes == null) { 108 attributes = new Hashtable (); 109 } 110 attributes.put(name, value); 111 112 try { 114 new DocumentBuilderImpl(this, attributes); 115 } catch (Exception e) { 116 attributes.remove(name); 117 throw new IllegalArgumentException (e.getMessage()); 118 } 119 } 120 121 125 public Object getAttribute(String name) 126 throws IllegalArgumentException 127 { 128 DOMParser domParser = null; 129 130 try { 131 domParser = 134 new DocumentBuilderImpl(this, attributes).getDOMParser(); 135 return domParser.getProperty(name); 136 } catch (SAXException se1) { 137 try { 139 boolean result = domParser.getFeature(name); 140 return new Boolean (result); 142 } catch (SAXException se2) { 143 throw new IllegalArgumentException (se1.getMessage()); 145 } 146 } 147 } 148 149 150 153 public void setFeature(String name, boolean value) throws ParserConfigurationException { 154 156 } 157 160 public boolean getFeature(String name) throws ParserConfigurationException { 161 return false; 163 } 164 165 } 166 | Popular Tags |