1 11 12 package org.eclipse.pde.internal.core.util; 13 14 import java.io.File ; 15 import java.io.IOException ; 16 import java.io.InputStream ; 17 18 import javax.xml.parsers.FactoryConfigurationError ; 19 import javax.xml.parsers.ParserConfigurationException ; 20 import javax.xml.parsers.SAXParser ; 21 22 import org.xml.sax.InputSource ; 23 import org.xml.sax.SAXException ; 24 import org.xml.sax.helpers.DefaultHandler ; 25 26 30 public class SAXParserWrapper { 31 32 protected SAXParser fParser; 33 protected boolean isdisposed; 34 35 38 public SAXParserWrapper() throws ParserConfigurationException , SAXException , FactoryConfigurationError { 39 fParser = PDEXMLHelper.Instance().getDefaultSAXParser(); 40 isdisposed = false; 41 } 42 43 public void dispose() { 45 if (isdisposed == false) { 46 PDEXMLHelper.Instance().recycleSAXParser(fParser); 47 isdisposed = true; 48 } 49 } 50 51 public void parse(File f, DefaultHandler dh) throws SAXException , IOException { 52 fParser.parse(f, dh); 53 } 54 55 public void parse(InputStream is, DefaultHandler dh) throws SAXException , IOException { 56 fParser.parse(is, dh); 57 } 58 59 public void parse(InputSource is, DefaultHandler dh) throws SAXException , IOException { 60 fParser.parse(is, dh); 61 } 62 63 66 protected void finalize() throws Throwable { 68 super.finalize(); 69 dispose(); 70 } 71 72 } 73 | Popular Tags |