author | serb |
Thu, 25 Dec 2014 22:48:13 +0300 | |
changeset 28535 | 74115b2c211f |
parent 27574 | 2e8afdf5c6fb |
child 28695 | 427254b89b9e |
permissions | -rw-r--r-- |
12005 | 1 |
/* |
22139
f4b2aa462b46
8029236: Update copyright year to match last edit in jdk8 jaxp repository for 2013
joehw
parents:
20581
diff
changeset
|
2 |
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. |
12005 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
7 |
* published by the Free Software Foundation. Oracle designates this |
|
8 |
* particular file as subject to the "Classpath" exception as provided |
|
9 |
* by Oracle in the LICENSE file that accompanied this code. |
|
10 |
* |
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
24 |
*/ |
|
25 |
||
26 |
package javax.xml.xpath; |
|
27 |
||
28 |
/** |
|
29 |
* <p>An <code>XPathFactory</code> instance can be used to create |
|
30 |
* {@link javax.xml.xpath.XPath} objects.</p> |
|
31 |
* |
|
32 |
*<p>See {@link #newInstance(String uri)} for lookup mechanism.</p> |
|
33 |
* |
|
34 |
* <p>The {@link XPathFactory} class is not thread-safe. In other words, |
|
35 |
* it is the application's responsibility to ensure that at most |
|
36 |
* one thread is using a {@link XPathFactory} object at any |
|
37 |
* given moment. Implementations are encouraged to mark methods |
|
38 |
* as <code>synchronized</code> to protect themselves from broken clients. |
|
39 |
* |
|
40 |
* <p>{@link XPathFactory} is not re-entrant. While one of the |
|
41 |
* <code>newInstance</code> methods is being invoked, applications |
|
42 |
* may not attempt to recursively invoke a <code>newInstance</code> method, |
|
43 |
* even from the same thread. |
|
44 |
* |
|
45 |
* @author <a href="mailto:Norman.Walsh@Sun.com">Norman Walsh</a> |
|
46 |
* @author <a href="mailto:Jeff.Suttor@Sun.com">Jeff Suttor</a> |
|
47 |
* |
|
48 |
* @since 1.5 |
|
49 |
*/ |
|
50 |
public abstract class XPathFactory { |
|
51 |
||
52 |
||
53 |
/** |
|
54 |
* <p>The default property name according to the JAXP spec.</p> |
|
55 |
*/ |
|
56 |
public static final String DEFAULT_PROPERTY_NAME = "javax.xml.xpath.XPathFactory"; |
|
57 |
||
58 |
/** |
|
59 |
* <p>Default Object Model URI.</p> |
|
60 |
*/ |
|
61 |
public static final String DEFAULT_OBJECT_MODEL_URI = "http://java.sun.com/jaxp/xpath/dom"; |
|
62 |
||
63 |
/** |
|
64 |
*<p> Take care of restrictions imposed by java security model </p> |
|
65 |
*/ |
|
66 |
private static SecuritySupport ss = new SecuritySupport() ; |
|
67 |
||
68 |
/** |
|
69 |
* <p>Protected constructor as {@link #newInstance()} or {@link #newInstance(String uri)} |
|
70 |
* or {@link #newInstance(String uri, String factoryClassName, ClassLoader classLoader)} |
|
71 |
* should be used to create a new instance of an <code>XPathFactory</code>.</p> |
|
72 |
*/ |
|
73 |
protected XPathFactory() { |
|
74 |
} |
|
75 |
||
76 |
/** |
|
77 |
* <p>Get a new <code>XPathFactory</code> instance using the default object model, |
|
78 |
* {@link #DEFAULT_OBJECT_MODEL_URI}, |
|
79 |
* the W3C DOM.</p> |
|
80 |
* |
|
81 |
* <p>This method is functionally equivalent to:</p> |
|
82 |
* <pre> |
|
83 |
* newInstance(DEFAULT_OBJECT_MODEL_URI) |
|
84 |
* </pre> |
|
85 |
* |
|
86 |
* <p>Since the implementation for the W3C DOM is always available, this method will never fail.</p> |
|
87 |
* |
|
88 |
* @return Instance of an <code>XPathFactory</code>. |
|
89 |
* |
|
90 |
* @throws RuntimeException When there is a failure in creating an |
|
91 |
* <code>XPathFactory</code> for the default object model. |
|
92 |
*/ |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
93 |
public static XPathFactory newInstance() { |
12005 | 94 |
|
95 |
try { |
|
96 |
return newInstance(DEFAULT_OBJECT_MODEL_URI); |
|
97 |
} catch (XPathFactoryConfigurationException xpathFactoryConfigurationException) { |
|
98 |
throw new RuntimeException( |
|
99 |
"XPathFactory#newInstance() failed to create an XPathFactory for the default object model: " |
|
100 |
+ DEFAULT_OBJECT_MODEL_URI |
|
101 |
+ " with the XPathFactoryConfigurationException: " |
|
102 |
+ xpathFactoryConfigurationException.toString() |
|
103 |
); |
|
104 |
} |
|
105 |
} |
|
106 |
||
107 |
/** |
|
108 |
* <p>Get a new <code>XPathFactory</code> instance using the specified object model.</p> |
|
109 |
* |
|
110 |
* <p>To find a <code>XPathFactory</code> object, |
|
111 |
* this method looks the following places in the following order where "the class loader" refers to the context class loader:</p> |
|
112 |
* <ol> |
|
113 |
* <li> |
|
114 |
* If the system property {@link #DEFAULT_PROPERTY_NAME} + ":uri" is present, |
|
115 |
* where uri is the parameter to this method, then its value is read as a class name. |
|
116 |
* The method will try to create a new instance of this class by using the class loader, |
|
117 |
* and returns it if it is successfully created. |
|
118 |
* </li> |
|
119 |
* <li> |
|
27574 | 120 |
* ${java.home}/conf/jaxp.properties is read and the value associated with the key being the system property above is looked for. |
12005 | 121 |
* If present, the value is processed just like above. |
122 |
* </li> |
|
123 |
* <li> |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
124 |
* Use the service-provider loading facilities, defined by the |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
125 |
* {@link java.util.ServiceLoader} class, to attempt to locate and load an |
20581
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
126 |
* implementation of the service using the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
127 |
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}: |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
128 |
* the service-provider loading facility will use the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
129 |
* java.lang.Thread#getContextClassLoader() current thread's context class loader} |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
130 |
* to attempt to load the service. If the context class |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
131 |
* loader is null, the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
132 |
* ClassLoader#getSystemClassLoader() system class loader} will be used. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
133 |
* <br> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
134 |
* Each potential service provider is required to implement the method |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
135 |
* {@link #isObjectModelSupported(String objectModel)}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
136 |
* The first service provider found that supports the specified object |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
137 |
* model is returned. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
138 |
* <br> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
139 |
* In case of {@link java.util.ServiceConfigurationError} an |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
140 |
* {@link XPathFactoryConfigurationException} will be thrown. |
12005 | 141 |
* </li> |
142 |
* <li> |
|
143 |
* Platform default <code>XPathFactory</code> is located in a platform specific way. |
|
144 |
* There must be a platform default XPathFactory for the W3C DOM, i.e. {@link #DEFAULT_OBJECT_MODEL_URI}. |
|
145 |
* </li> |
|
146 |
* </ol> |
|
147 |
* <p>If everything fails, an <code>XPathFactoryConfigurationException</code> will be thrown.</p> |
|
148 |
* |
|
149 |
* <p>Tip for Trouble-shooting:</p> |
|
150 |
* <p>See {@link java.util.Properties#load(java.io.InputStream)} for exactly how a property file is parsed. |
|
151 |
* In particular, colons ':' need to be escaped in a property file, so make sure the URIs are properly escaped in it. |
|
152 |
* For example:</p> |
|
153 |
* <pre> |
|
154 |
* http\://java.sun.com/jaxp/xpath/dom=org.acme.DomXPathFactory |
|
155 |
* </pre> |
|
156 |
* |
|
157 |
* @param uri Identifies the underlying object model. |
|
158 |
* The specification only defines the URI {@link #DEFAULT_OBJECT_MODEL_URI}, |
|
159 |
* <code>http://java.sun.com/jaxp/xpath/dom</code> for the W3C DOM, |
|
160 |
* the org.w3c.dom package, and implementations are free to introduce other URIs for other object models. |
|
161 |
* |
|
162 |
* @return Instance of an <code>XPathFactory</code>. |
|
163 |
* |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
164 |
* @throws XPathFactoryConfigurationException If the specified object model |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
165 |
* is unavailable, or if there is a configuration error. |
12005 | 166 |
* @throws NullPointerException If <code>uri</code> is <code>null</code>. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
167 |
* @throws IllegalArgumentException If <code>uri</code> is <code>null</code> |
12005 | 168 |
* or <code>uri.length() == 0</code>. |
169 |
*/ |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
170 |
public static XPathFactory newInstance(final String uri) |
12005 | 171 |
throws XPathFactoryConfigurationException { |
172 |
||
173 |
if (uri == null) { |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
174 |
throw new NullPointerException( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
175 |
"XPathFactory#newInstance(String uri) cannot be called with uri == null"); |
12005 | 176 |
} |
177 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
178 |
if (uri.length() == 0) { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
179 |
throw new IllegalArgumentException( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
180 |
"XPathFactory#newInstance(String uri) cannot be called with uri == \"\""); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
181 |
} |
12005 | 182 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
183 |
ClassLoader classLoader = ss.getContextClassLoader(); |
12005 | 184 |
|
185 |
if (classLoader == null) { |
|
186 |
//use the current class loader |
|
187 |
classLoader = XPathFactory.class.getClassLoader(); |
|
188 |
} |
|
189 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
190 |
XPathFactory xpathFactory = new XPathFactoryFinder(classLoader).newFactory(uri); |
12005 | 191 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
192 |
if (xpathFactory == null) { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
193 |
throw new XPathFactoryConfigurationException( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
194 |
"No XPathFactory implementation found for the object model: " |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
195 |
+ uri); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
196 |
} |
12005 | 197 |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
198 |
return xpathFactory; |
12005 | 199 |
} |
200 |
||
201 |
/** |
|
202 |
* <p>Obtain a new instance of a <code>XPathFactory</code> from a factory class name. <code>XPathFactory</code> |
|
203 |
* is returned if specified factory class supports the specified object model. |
|
204 |
* This function is useful when there are multiple providers in the classpath. |
|
205 |
* It gives more control to the application as it can specify which provider |
|
206 |
* should be loaded.</p> |
|
207 |
* |
|
208 |
* |
|
209 |
* <h2>Tip for Trouble-shooting</h2> |
|
210 |
* <p>Setting the <code>jaxp.debug</code> system property will cause |
|
211 |
* this method to print a lot of debug messages |
|
212 |
* to <code>System.err</code> about what it is doing and where it is looking at.</p> |
|
213 |
* |
|
214 |
* <p> If you have problems try:</p> |
|
215 |
* <pre> |
|
216 |
* java -Djaxp.debug=1 YourProgram .... |
|
217 |
* </pre> |
|
218 |
* |
|
219 |
* @param uri Identifies the underlying object model. The specification only defines the URI |
|
220 |
* {@link #DEFAULT_OBJECT_MODEL_URI},<code>http://java.sun.com/jaxp/xpath/dom</code> |
|
221 |
* for the W3C DOM, the org.w3c.dom package, and implementations are free to introduce |
|
222 |
* other URIs for other object models. |
|
223 |
* |
|
224 |
* @param factoryClassName fully qualified factory class name that provides implementation of <code>javax.xml.xpath.XPathFactory</code>. |
|
225 |
* |
|
226 |
* @param classLoader <code>ClassLoader</code> used to load the factory class. If <code>null</code> |
|
227 |
* current <code>Thread</code>'s context classLoader is used to load the factory class. |
|
228 |
* |
|
229 |
* |
|
230 |
* @return New instance of a <code>XPathFactory</code> |
|
231 |
* |
|
232 |
* @throws XPathFactoryConfigurationException |
|
233 |
* if <code>factoryClassName</code> is <code>null</code>, or |
|
234 |
* the factory class cannot be loaded, instantiated |
|
235 |
* or the factory class does not support the object model specified |
|
236 |
* in the <code>uri</code> parameter. |
|
237 |
* |
|
238 |
* @throws NullPointerException If <code>uri</code> is <code>null</code>. |
|
239 |
* @throws IllegalArgumentException If <code>uri</code> is <code>null</code> |
|
240 |
* or <code>uri.length() == 0</code>. |
|
241 |
* |
|
242 |
* @see #newInstance() |
|
243 |
* @see #newInstance(String uri) |
|
244 |
* |
|
245 |
* @since 1.6 |
|
246 |
*/ |
|
247 |
public static XPathFactory newInstance(String uri, String factoryClassName, ClassLoader classLoader) |
|
248 |
throws XPathFactoryConfigurationException{ |
|
249 |
ClassLoader cl = classLoader; |
|
250 |
||
251 |
if (uri == null) { |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
252 |
throw new NullPointerException( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
253 |
"XPathFactory#newInstance(String uri) cannot be called with uri == null"); |
12005 | 254 |
} |
255 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
256 |
if (uri.length() == 0) { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
257 |
throw new IllegalArgumentException( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
258 |
"XPathFactory#newInstance(String uri) cannot be called with uri == \"\""); |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
259 |
} |
12005 | 260 |
|
261 |
if (cl == null) { |
|
262 |
cl = ss.getContextClassLoader(); |
|
263 |
} |
|
264 |
||
265 |
XPathFactory f = new XPathFactoryFinder(cl).createInstance(factoryClassName); |
|
266 |
||
267 |
if (f == null) { |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
268 |
throw new XPathFactoryConfigurationException( |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
269 |
"No XPathFactory implementation found for the object model: " |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
270 |
+ uri); |
12005 | 271 |
} |
272 |
//if this factory supports the given schemalanguage return this factory else thrown exception |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
273 |
if (f.isObjectModelSupported(uri)) { |
12005 | 274 |
return f; |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
275 |
} else { |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
276 |
throw new XPathFactoryConfigurationException("Factory " |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
277 |
+ factoryClassName + " doesn't support given " + uri |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
278 |
+ " object model"); |
12005 | 279 |
} |
280 |
||
281 |
} |
|
282 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
283 |
/** |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
284 |
* <p>Is specified object model supported by this <code>XPathFactory</code>?</p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
285 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
286 |
* @param objectModel Specifies the object model which the returned <code>XPathFactory</code> will understand. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
287 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
288 |
* @return <code>true</code> if <code>XPathFactory</code> supports <code>objectModel</code>, else <code>false</code>. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
289 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
290 |
* @throws NullPointerException If <code>objectModel</code> is <code>null</code>. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
291 |
* @throws IllegalArgumentException If <code>objectModel.length() == 0</code>. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
292 |
*/ |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
293 |
public abstract boolean isObjectModelSupported(String objectModel); |
12005 | 294 |
|
295 |
/** |
|
296 |
* <p>Set a feature for this <code>XPathFactory</code> and |
|
297 |
* <code>XPath</code>s created by this factory.</p> |
|
298 |
* |
|
299 |
* <p> |
|
300 |
* Feature names are fully qualified {@link java.net.URI}s. |
|
301 |
* Implementations may define their own features. |
|
302 |
* An {@link XPathFactoryConfigurationException} is thrown if this |
|
303 |
* <code>XPathFactory</code> or the <code>XPath</code>s |
|
304 |
* it creates cannot support the feature. |
|
305 |
* It is possible for an <code>XPathFactory</code> to expose a feature value |
|
306 |
* but be unable to change its state. |
|
307 |
* </p> |
|
308 |
* |
|
309 |
* <p> |
|
310 |
* All implementations are required to support the {@link javax.xml.XMLConstants#FEATURE_SECURE_PROCESSING} feature. |
|
311 |
* When the feature is <code>true</code>, any reference to an external function is an error. |
|
312 |
* Under these conditions, the implementation must not call the {@link XPathFunctionResolver} |
|
313 |
* and must throw an {@link XPathFunctionException}. |
|
314 |
* </p> |
|
315 |
* |
|
316 |
* @param name Feature name. |
|
317 |
* @param value Is feature state <code>true</code> or <code>false</code>. |
|
318 |
* |
|
319 |
* @throws XPathFactoryConfigurationException if this <code>XPathFactory</code> or the <code>XPath</code>s |
|
320 |
* it creates cannot support this feature. |
|
321 |
* @throws NullPointerException if <code>name</code> is <code>null</code>. |
|
322 |
*/ |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
323 |
public abstract void setFeature(String name, boolean value) |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
324 |
throws XPathFactoryConfigurationException; |
12005 | 325 |
|
326 |
/** |
|
327 |
* <p>Get the state of the named feature.</p> |
|
328 |
* |
|
329 |
* <p> |
|
330 |
* Feature names are fully qualified {@link java.net.URI}s. |
|
331 |
* Implementations may define their own features. |
|
332 |
* An {@link XPathFactoryConfigurationException} is thrown if this |
|
333 |
* <code>XPathFactory</code> or the <code>XPath</code>s |
|
334 |
* it creates cannot support the feature. |
|
335 |
* It is possible for an <code>XPathFactory</code> to expose a feature value |
|
336 |
* but be unable to change its state. |
|
337 |
* </p> |
|
338 |
* |
|
339 |
* @param name Feature name. |
|
340 |
* |
|
341 |
* @return State of the named feature. |
|
342 |
* |
|
343 |
* @throws XPathFactoryConfigurationException if this |
|
344 |
* <code>XPathFactory</code> or the <code>XPath</code>s |
|
345 |
* it creates cannot support this feature. |
|
346 |
* @throws NullPointerException if <code>name</code> is <code>null</code>. |
|
347 |
*/ |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
348 |
public abstract boolean getFeature(String name) |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
349 |
throws XPathFactoryConfigurationException; |
12005 | 350 |
|
351 |
/** |
|
352 |
* <p>Establish a default variable resolver.</p> |
|
353 |
* |
|
354 |
* <p>Any <code>XPath</code> objects constructed from this factory will use |
|
355 |
* the specified resolver by default.</p> |
|
356 |
* |
|
357 |
* <p>A <code>NullPointerException</code> is thrown if <code>resolver</code> |
|
358 |
* is <code>null</code>.</p> |
|
359 |
* |
|
360 |
* @param resolver Variable resolver. |
|
361 |
* |
|
362 |
* @throws NullPointerException If <code>resolver</code> is |
|
363 |
* <code>null</code>. |
|
364 |
*/ |
|
365 |
public abstract void setXPathVariableResolver(XPathVariableResolver resolver); |
|
366 |
||
367 |
/** |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
368 |
* <p>Establish a default function resolver.</p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
369 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
370 |
* <p>Any <code>XPath</code> objects constructed from this factory will |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
371 |
* use the specified resolver by default.</p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
372 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
373 |
* <p>A <code>NullPointerException</code> is thrown if |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
374 |
* <code>resolver</code> is <code>null</code>.</p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
375 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
376 |
* @param resolver XPath function resolver. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
377 |
* |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
378 |
* @throws NullPointerException If <code>resolver</code> is |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
379 |
* <code>null</code>. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
380 |
*/ |
12005 | 381 |
public abstract void setXPathFunctionResolver(XPathFunctionResolver resolver); |
382 |
||
383 |
/** |
|
384 |
* <p>Return a new <code>XPath</code> using the underlying object |
|
385 |
* model determined when the <code>XPathFactory</code> was instantiated.</p> |
|
386 |
* |
|
387 |
* @return New instance of an <code>XPath</code>. |
|
388 |
*/ |
|
389 |
public abstract XPath newXPath(); |
|
390 |
} |