1 3 9 10 package javax.xml.xpath; 11 12 23 public abstract class XPathFactory { 24 25 26 29 public static final String DEFAULT_PROPERTY_NAME = "javax.xml.xpath.XPathFactory"; 30 31 34 public static final String DEFAULT_OBJECT_MODEL_URI = "http://java.sun.com/jaxp/xpath/dom"; 35 36 39 private static SecuritySupport ss = new SecuritySupport () ; 40 41 45 protected XPathFactory() { 46 } 47 48 62 public static final XPathFactory newInstance() { 63 64 try { 65 return newInstance(DEFAULT_OBJECT_MODEL_URI); 66 } catch (XPathFactoryConfigurationException xpathFactoryConfigurationException) { 67 throw new RuntimeException ( 68 "XPathFactory#newInstance() failed to create an XPathFactory for the default object model: " 69 + DEFAULT_OBJECT_MODEL_URI 70 + " with the XPathFactoryConfigurationException: " 71 + xpathFactoryConfigurationException.toString() 72 ); 73 } 74 } 75 76 128 public static final XPathFactory newInstance(final String uri) 129 throws XPathFactoryConfigurationException { 130 131 if (uri == null) { 132 throw new NullPointerException ( 133 "XPathFactory#newInstance(String uri) cannot be called with uri == null" 134 ); 135 } 136 137 if (uri.length() == 0) { 138 throw new IllegalArgumentException ( 139 "XPathFactory#newInstance(String uri) cannot be called with uri == \"\"" 140 ); 141 } 142 143 ClassLoader classLoader = ss.getContextClassLoader(); 144 145 if (classLoader == null) { 146 classLoader = XPathFactory .class.getClassLoader(); 148 } 149 150 XPathFactory xpathFactory = new XPathFactoryFinder (classLoader).newFactory(uri); 151 152 if (xpathFactory == null) { 153 throw new XPathFactoryConfigurationException ( 154 "No XPathFctory implementation found for the object model: " 155 + uri 156 ); 157 } 158 159 return xpathFactory; 160 } 161 162 172 public abstract boolean isObjectModelSupported(String objectModel); 173 174 199 public abstract void setFeature(String name, boolean value) 200 throws XPathFactoryConfigurationException ; 201 202 221 public abstract boolean getFeature(String name) 222 throws XPathFactoryConfigurationException ; 223 224 236 public abstract void setXPathVariableResolver(XPathVariableResolver resolver); 237 238 250 public abstract void setXPathFunctionResolver(XPathFunctionResolver resolver); 251 252 258 public abstract XPath newXPath(); 259 } 260 | Popular Tags |