1 18 19 package org.apache.batik.util; 20 21 import java.io.InputStream ; 22 import java.io.IOException ; 23 import java.util.Properties ; 24 import java.util.MissingResourceException ; 25 26 33 public class XMLResourceDescriptor { 34 35 38 public final static String XML_PARSER_CLASS_NAME_KEY = 39 "org.xml.sax.driver"; 40 41 44 public final static String CSS_PARSER_CLASS_NAME_KEY = 45 "org.w3c.css.sac.driver"; 46 47 50 public final static String RESOURCES = 51 "resources/XMLResourceDescriptor.properties"; 52 53 56 protected static Properties parserProps = null;; 57 58 61 protected static String xmlParserClassName; 62 63 66 protected static String cssParserClassName; 67 68 protected static synchronized Properties getParserProps() { 69 if (parserProps != null) return parserProps; 70 71 parserProps = new Properties (); 72 try { 73 Class cls = XMLResourceDescriptor.class; 74 InputStream is = cls.getResourceAsStream(RESOURCES); 75 parserProps.load(is); 76 } catch (IOException ioe) { 77 throw new MissingResourceException (ioe.getMessage(), 78 RESOURCES, null); 79 } 80 return parserProps; 81 } 82 83 91 public static String getXMLParserClassName() { 92 if (xmlParserClassName == null) { 93 xmlParserClassName = getParserProps().getProperty 94 (XML_PARSER_CLASS_NAME_KEY); 95 } 96 return xmlParserClassName; 97 } 98 99 104 public static void setXMLParserClassName(String xmlParserClassName) { 105 XMLResourceDescriptor.xmlParserClassName = xmlParserClassName; 106 } 107 108 118 public static String getCSSParserClassName() { 119 if (cssParserClassName == null) { 120 cssParserClassName = getParserProps().getProperty 121 (CSS_PARSER_CLASS_NAME_KEY); 122 } 123 return cssParserClassName; 124 } 125 126 131 public static void setCSSParserClassName(String cssParserClassName) { 132 XMLResourceDescriptor.cssParserClassName = cssParserClassName; 133 } 134 } 135 | Popular Tags |