1 11 12 package org.eclipse.pde.internal.core.util; 13 14 import java.io.File ; 15 import java.io.IOException ; 16 17 import javax.xml.parsers.DocumentBuilder ; 18 import javax.xml.parsers.FactoryConfigurationError ; 19 import javax.xml.parsers.ParserConfigurationException ; 20 21 import org.w3c.dom.Document ; 22 import org.xml.sax.SAXException ; 23 24 28 public class DOMParserWrapper { 29 30 protected DocumentBuilder fParser; 31 protected boolean isdisposed; 32 33 36 public DOMParserWrapper() throws ParserConfigurationException , FactoryConfigurationError { 37 fParser = PDEXMLHelper.Instance().getDefaultDOMParser(); 38 isdisposed = false; 39 } 40 41 public void dispose() { 43 if (isdisposed == false) { 44 PDEXMLHelper.Instance().recycleDOMParser(fParser); 45 isdisposed = true; 46 } 47 } 48 49 public Document parse(File f) throws SAXException , IOException { 50 return fParser.parse(f); 51 } 52 53 public Document newDocument() { 54 return fParser.newDocument(); 55 } 56 57 60 protected void finalize() throws Throwable { 62 super.finalize(); 63 dispose(); 64 } 65 66 } 67 | Popular Tags |