1 17 18 19 package org.apache.commons.digester; 20 21 import java.util.Properties ; 22 23 import javax.xml.parsers.ParserConfigurationException ; 24 import javax.xml.parsers.SAXParser ; 25 26 import org.apache.commons.digester.parser.GenericParser; 27 import org.apache.commons.digester.parser.XercesParser; 28 29 import org.xml.sax.SAXException ; 30 import org.xml.sax.SAXNotRecognizedException ; 31 import org.xml.sax.SAXNotSupportedException ; 32 33 40 public class ParserFeatureSetterFactory{ 41 42 45 private static boolean isXercesUsed; 46 47 static { 48 try{ 49 Class versionClass = 51 Class.forName("org.apache.xerces.impl.Version"); 52 isXercesUsed = true; 53 } catch (Exception ex){ 54 isXercesUsed = false; 55 } 56 } 57 58 64 public static SAXParser newSAXParser(Properties properties) 65 throws ParserConfigurationException , 66 SAXException , 67 SAXNotRecognizedException , 68 SAXNotSupportedException { 69 70 if (isXercesUsed){ 71 return XercesParser.newSAXParser(properties); 72 } else { 73 return GenericParser.newSAXParser(properties); 74 } 75 } 76 77 } | Popular Tags |