1 8 9 package javax.xml.parsers; 10 11 import java.io.File ; 12 import java.io.IOException ; 13 import java.io.InputStream ; 14 15 import javax.xml.validation.Schema ; 16 17 import org.w3c.dom.Document ; 18 import org.w3c.dom.DOMImplementation ; 19 20 import org.xml.sax.EntityResolver ; 21 import org.xml.sax.ErrorHandler ; 22 import org.xml.sax.InputSource ; 23 import org.xml.sax.SAXException ; 24 25 45 46 public abstract class DocumentBuilder { 47 48 49 50 protected DocumentBuilder () { 51 } 52 53 67 public void reset() { 68 69 throw new UnsupportedOperationException ( 71 "This DocumentBuilder, \"" + this.getClass().getName() + "\", does not support the reset functionality." 72 + " Specification \"" + this.getClass().getPackage().getSpecificationTitle() + "\"" 73 + " version \"" + this.getClass().getPackage().getSpecificationVersion() + "\"" 74 ); 75 } 76 77 90 91 public Document parse(InputStream is) 92 throws SAXException , IOException { 93 if (is == null) { 94 throw new IllegalArgumentException ("InputStream cannot be null"); 95 } 96 97 InputSource in = new InputSource (is); 98 return parse(in); 99 } 100 101 114 115 public Document parse(InputStream is, String systemId) 116 throws SAXException , IOException { 117 if (is == null) { 118 throw new IllegalArgumentException ("InputStream cannot be null"); 119 } 120 121 InputSource in = new InputSource (is); 122 in.setSystemId(systemId); 123 return parse(in); 124 } 125 126 138 139 public Document parse(String uri) 140 throws SAXException , IOException { 141 if (uri == null) { 142 throw new IllegalArgumentException ("URI cannot be null"); 143 } 144 145 InputSource in = new InputSource (uri); 146 return parse(in); 147 } 148 149 161 162 public Document parse(File f) throws SAXException , IOException { 163 if (f == null) { 164 throw new IllegalArgumentException ("File cannot be null"); 165 } 166 167 String uri = "file:" + f.getAbsolutePath(); 168 if (File.separatorChar == '\\') { 169 uri = uri.replace('\\', '/'); 170 } 171 InputSource in = new InputSource (uri); 172 return parse(in); 173 } 174 175 187 188 public abstract Document parse(InputSource is) 189 throws SAXException , IOException ; 190 191 192 199 200 public abstract boolean isNamespaceAware(); 201 202 209 210 public abstract boolean isValidating(); 211 212 222 223 public abstract void setEntityResolver(EntityResolver er); 224 225 233 234 public abstract void setErrorHandler(ErrorHandler eh); 235 236 242 243 public abstract Document newDocument(); 244 245 250 251 public abstract DOMImplementation getDOMImplementation(); 252 253 257 262 263 278 public Schema getSchema() { 279 throw new UnsupportedOperationException ( 280 "This parser does not support specification \"" 281 + this.getClass().getPackage().getSpecificationTitle() 282 + "\" version \"" 283 + this.getClass().getPackage().getSpecificationVersion() 284 + "\"" 285 ); 286 } 287 288 289 306 public boolean isXIncludeAware() { 307 throw new UnsupportedOperationException ( 308 "This parser does not support specification \"" 309 + this.getClass().getPackage().getSpecificationTitle() 310 + "\" version \"" 311 + this.getClass().getPackage().getSpecificationVersion() 312 + "\"" 313 ); 314 } 315 } 316 | Popular Tags |