author | avstepan |
Tue, 21 Apr 2015 20:01:21 +0400 | |
changeset 29999 | 8493f5fc1052 |
parent 29419 | 534054ee6062 |
child 42390 | 4083bc2c3b5b |
permissions | -rw-r--r-- |
12005 | 1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
3 |
* |
|
4 |
* This code is free software; you can redistribute it and/or modify it |
|
5 |
* under the terms of the GNU General Public License version 2 only, as |
|
6 |
* published by the Free Software Foundation. Oracle designates this |
|
7 |
* particular file as subject to the "Classpath" exception as provided |
|
8 |
* by Oracle in the LICENSE file that accompanied this code. |
|
9 |
* |
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
14 |
* accompanied this code). |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License version |
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 |
* |
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
21 |
* or visit www.oracle.com if you need additional information or have any |
|
22 |
* questions. |
|
23 |
*/ |
|
24 |
||
25 |
/* |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
26 |
* Copyright (c) 2009, 2013, by Oracle Corporation. All Rights Reserved. |
12005 | 27 |
*/ |
28 |
||
29 |
package javax.xml.stream; |
|
30 |
||
31 |
import javax.xml.transform.Result; |
|
32 |
||
33 |
/** |
|
34 |
* Defines an abstract implementation of a factory for |
|
35 |
* getting XMLEventWriters and XMLStreamWriters. |
|
36 |
* |
|
37 |
* The following table defines the standard properties of this specification. |
|
38 |
* Each property varies in the level of support required by each implementation. |
|
39 |
* The level of support required is described in the 'Required' column. |
|
40 |
* |
|
41 |
* <table border="2" rules="all" cellpadding="4"> |
|
42 |
* <thead> |
|
43 |
* <tr> |
|
44 |
* <th align="center" colspan="2"> |
|
45 |
* Configuration parameters |
|
46 |
* </th> |
|
47 |
* </tr> |
|
48 |
* </thead> |
|
49 |
* <tbody> |
|
50 |
* <tr> |
|
51 |
* <th>Property Name</th> |
|
52 |
* <th>Behavior</th> |
|
53 |
* <th>Return type</th> |
|
54 |
* <th>Default Value</th> |
|
55 |
* <th>Required</th> |
|
56 |
* </tr> |
|
29999 | 57 |
* <tr><td>javax.xml.stream.isRepairingNamespaces</td><td>defaults prefixes |
58 |
* on the output side</td><td>Boolean</td><td>False</td><td>Yes</td></tr> |
|
12005 | 59 |
* </tbody> |
60 |
* </table> |
|
61 |
* |
|
29999 | 62 |
* <p>The following paragraphs describe the namespace and prefix repair algorithm: |
12005 | 63 |
* |
64 |
* <p>The property can be set with the following code line: |
|
29999 | 65 |
* {@code setProperty("javax.xml.stream.isRepairingNamespaces", new Boolean(true|false));} |
12005 | 66 |
* |
67 |
* <p>This property specifies that the writer default namespace prefix declarations. |
|
29999 | 68 |
* The default value is false. |
12005 | 69 |
* |
70 |
* <p>If a writer isRepairingNamespaces it will create a namespace declaration |
|
71 |
* on the current StartElement for |
|
72 |
* any attribute that does not |
|
73 |
* currently have a namespace declaration in scope. If the StartElement |
|
74 |
* has a uri but no prefix specified a prefix will be assigned, if the prefix |
|
75 |
* has not been declared in a parent of the current StartElement it will be declared |
|
76 |
* on the current StartElement. If the defaultNamespace is bound and in scope |
|
77 |
* and the default namespace matches the URI of the attribute or StartElement |
|
29999 | 78 |
* QName no prefix will be assigned. |
12005 | 79 |
* |
80 |
* <p>If an element or attribute name has a prefix, but is not |
|
81 |
* bound to any namespace URI, then the prefix will be removed |
|
29999 | 82 |
* during serialization. |
12005 | 83 |
* |
84 |
* <p>If element and/or attribute names in the same start or |
|
85 |
* empty-element tag are bound to different namespace URIs and |
|
86 |
* are using the same prefix then the element or the first |
|
87 |
* occurring attribute retains the original prefix and the |
|
88 |
* following attributes have their prefixes replaced with a |
|
89 |
* new prefix that is bound to the namespace URIs of those |
|
29999 | 90 |
* attributes. |
12005 | 91 |
* |
92 |
* <p>If an element or attribute name uses a prefix that is |
|
93 |
* bound to a different URI than that inherited from the |
|
94 |
* namespace context of the parent of that element and there |
|
95 |
* is no namespace declaration in the context of the current |
|
29999 | 96 |
* element then such a namespace declaration is added. |
12005 | 97 |
* |
98 |
* <p>If an element or attribute name is bound to a prefix and |
|
99 |
* there is a namespace declaration that binds that prefix |
|
100 |
* to a different URI then that namespace declaration is |
|
101 |
* either removed if the correct mapping is inherited from |
|
102 |
* the parent context of that element, or changed to the |
|
29999 | 103 |
* namespace URI of the element or attribute using that prefix. |
12005 | 104 |
* |
105 |
* @version 1.2 |
|
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
106 |
* @author Copyright (c) 2009, 2015 by Oracle Corporation. All Rights Reserved. |
12005 | 107 |
* @see XMLInputFactory |
108 |
* @see XMLEventWriter |
|
109 |
* @see XMLStreamWriter |
|
110 |
* @since 1.6 |
|
111 |
*/ |
|
112 |
public abstract class XMLOutputFactory { |
|
113 |
/** |
|
114 |
* Property used to set prefix defaulting on the output side |
|
115 |
*/ |
|
116 |
public static final String IS_REPAIRING_NAMESPACES= |
|
117 |
"javax.xml.stream.isRepairingNamespaces"; |
|
118 |
||
119 |
static final String DEFAULIMPL = "com.sun.xml.internal.stream.XMLOutputFactoryImpl"; |
|
120 |
||
121 |
protected XMLOutputFactory(){} |
|
122 |
||
123 |
/** |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
124 |
* Creates a new instance of the factory in exactly the same manner as the |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
125 |
* {@link #newFactory()} method. |
12005 | 126 |
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded |
127 |
*/ |
|
128 |
public static XMLOutputFactory newInstance() |
|
129 |
throws FactoryConfigurationError |
|
130 |
{ |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
131 |
return FactoryFinder.find(XMLOutputFactory.class, DEFAULIMPL); |
12005 | 132 |
} |
133 |
||
134 |
/** |
|
135 |
* Create a new instance of the factory. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
136 |
* <p> |
12005 | 137 |
* This static method creates a new factory instance. This method uses the |
138 |
* following ordered lookup procedure to determine the XMLOutputFactory |
|
139 |
* implementation class to load: |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
140 |
* <ul> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
141 |
* <li> |
12005 | 142 |
* Use the javax.xml.stream.XMLOutputFactory system property. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
143 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
144 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
145 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
146 |
* Use the configuration file "stax.properties". The file is in standard |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
147 |
* {@link java.util.Properties} format and typically located in the |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
148 |
* {@code conf} directory of the Java installation. It contains the fully qualified |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
149 |
* name of the implementation class with the key being the system property |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
150 |
* defined above. |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
151 |
* |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
152 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
153 |
* The stax.properties file is read only once by the implementation |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
154 |
* and its values are then cached for future use. If the file does not exist |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
155 |
* when the first attempt is made to read from it, no further attempts are |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
156 |
* made to check for its existence. It is not possible to change the value |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
157 |
* of any property in stax.properties after it has been read for the first time. |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
158 |
* |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
159 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
160 |
* Use the jaxp configuration file "jaxp.properties". The file is in the same |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
161 |
* format as stax.properties and will only be read if stax.properties does |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
162 |
* not exist. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
163 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
164 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
165 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
166 |
* Use the service-provider loading facility, defined by the |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
167 |
* {@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
|
168 |
* implementation of the service using the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
169 |
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}: |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
170 |
* the service-provider loading facility will use the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
171 |
* java.lang.Thread#getContextClassLoader() current thread's context class loader} |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
172 |
* to attempt to load the service. If the context class |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
173 |
* loader is null, the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
174 |
* ClassLoader#getSystemClassLoader() system class loader} will be used. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
175 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
176 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
177 |
* <p> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
178 |
* Otherwise, the system-default implementation is returned. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
179 |
* </li> |
29999 | 180 |
* </ul> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
181 |
* <p> |
12005 | 182 |
* Once an application has obtained a reference to a XMLOutputFactory it |
183 |
* can use the factory to configure and obtain stream instances. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
184 |
* <p> |
12005 | 185 |
* Note that this is a new method that replaces the deprecated newInstance() method. |
186 |
* No changes in behavior are defined by this replacement method relative to the |
|
187 |
* deprecated method. |
|
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
188 |
* |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
189 |
* @throws FactoryConfigurationError in case of {@linkplain |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
190 |
* java.util.ServiceConfigurationError service configuration error} or if |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
191 |
* the implementation is not available or cannot be instantiated. |
12005 | 192 |
*/ |
193 |
public static XMLOutputFactory newFactory() |
|
194 |
throws FactoryConfigurationError |
|
195 |
{ |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
196 |
return FactoryFinder.find(XMLOutputFactory.class, DEFAULIMPL); |
12005 | 197 |
} |
198 |
||
199 |
/** |
|
200 |
* Create a new instance of the factory. |
|
201 |
* |
|
202 |
* @param factoryId Name of the factory to find, same as |
|
203 |
* a property name |
|
204 |
* @param classLoader classLoader to use |
|
205 |
* @return the factory implementation |
|
206 |
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded |
|
207 |
* |
|
208 |
* @deprecated This method has been deprecated because it returns an |
|
209 |
* instance of XMLInputFactory, which is of the wrong class. |
|
210 |
* Use the new method {@link #newFactory(java.lang.String, |
|
211 |
* java.lang.ClassLoader)} instead. |
|
212 |
*/ |
|
213 |
public static XMLInputFactory newInstance(String factoryId, |
|
214 |
ClassLoader classLoader) |
|
215 |
throws FactoryConfigurationError { |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
216 |
//do not fallback if given classloader can't find the class, throw exception |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
217 |
return FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null); |
12005 | 218 |
} |
219 |
||
220 |
/** |
|
221 |
* Create a new instance of the factory. |
|
222 |
* If the classLoader argument is null, then the ContextClassLoader is used. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
223 |
* <p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
224 |
* This method uses the following ordered lookup procedure to determine |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
225 |
* the XMLOutputFactory implementation class to load: |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
226 |
* <ul> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
227 |
* <li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
228 |
* Use the value of the system property identified by {@code factoryId}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
229 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
230 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
231 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
232 |
* Use the configuration file "stax.properties". The file is in standard |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
233 |
* {@link java.util.Properties} format and typically located in the |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
234 |
* {@code conf} directory of the Java installation. It contains the fully qualified |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
235 |
* name of the implementation class with the key being the system property |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
236 |
* defined above. |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
237 |
* |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
238 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
239 |
* The stax.properties file is read only once by the implementation |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
240 |
* and its values are then cached for future use. If the file does not exist |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
241 |
* when the first attempt is made to read from it, no further attempts are |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
242 |
* made to check for its existence. It is not possible to change the value |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
243 |
* of any property in stax.properties after it has been read for the first time. |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
244 |
* |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
245 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
246 |
* Use the jaxp configuration file "jaxp.properties". The file is in the same |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
247 |
* format as stax.properties and will only be read if stax.properties does |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
248 |
* not exist. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
249 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
250 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
251 |
* <p> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
252 |
* If {@code factoryId} is "javax.xml.stream.XMLOutputFactory", |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
253 |
* use the service-provider loading facility, defined by the |
22673
382d136fbba2
8032392: Spec: javax.xml.stream.XMLEventFactory/XMLOutputFactory/XMLInputFactory.newFactory(String, ClassLoader) referring to ServiceLoader.load(Class, ClassLoader)
joehw
parents:
22141
diff
changeset
|
254 |
* {@link java.util.ServiceLoader} class, to attempt to {@linkplain |
382d136fbba2
8032392: Spec: javax.xml.stream.XMLEventFactory/XMLOutputFactory/XMLInputFactory.newFactory(String, ClassLoader) referring to ServiceLoader.load(Class, ClassLoader)
joehw
parents:
22141
diff
changeset
|
255 |
* java.util.ServiceLoader#load(java.lang.Class, java.lang.ClassLoader) locate and load} |
382d136fbba2
8032392: Spec: javax.xml.stream.XMLEventFactory/XMLOutputFactory/XMLInputFactory.newFactory(String, ClassLoader) referring to ServiceLoader.load(Class, ClassLoader)
joehw
parents:
22141
diff
changeset
|
256 |
* an implementation of the service using the specified {@code ClassLoader}. |
21997
65d2e8e1d666
8027973: Error in the documentation for newFactory method of the javax.xml.stream factories
joehw
parents:
20581
diff
changeset
|
257 |
* If {@code classLoader} is null, the {@linkplain |
65d2e8e1d666
8027973: Error in the documentation for newFactory method of the javax.xml.stream factories
joehw
parents:
20581
diff
changeset
|
258 |
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism} will apply: |
65d2e8e1d666
8027973: Error in the documentation for newFactory method of the javax.xml.stream factories
joehw
parents:
20581
diff
changeset
|
259 |
* That is, the service-provider loading facility will use the {@linkplain |
20581
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
260 |
* java.lang.Thread#getContextClassLoader() current thread's context class loader} |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
261 |
* to attempt to load the service. If the context class |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
262 |
* loader is null, the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
263 |
* ClassLoader#getSystemClassLoader() system class loader} will be used. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
264 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
265 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
266 |
* <p> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
267 |
* Otherwise, throws a {@link FactoryConfigurationError}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
268 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
269 |
* </ul> |
12005 | 270 |
* |
21997
65d2e8e1d666
8027973: Error in the documentation for newFactory method of the javax.xml.stream factories
joehw
parents:
20581
diff
changeset
|
271 |
* @apiNote The parameter factoryId defined here is inconsistent with that |
65d2e8e1d666
8027973: Error in the documentation for newFactory method of the javax.xml.stream factories
joehw
parents:
20581
diff
changeset
|
272 |
* of other JAXP factories where the first parameter is fully qualified |
65d2e8e1d666
8027973: Error in the documentation for newFactory method of the javax.xml.stream factories
joehw
parents:
20581
diff
changeset
|
273 |
* factory class name that provides implementation of the factory. |
65d2e8e1d666
8027973: Error in the documentation for newFactory method of the javax.xml.stream factories
joehw
parents:
20581
diff
changeset
|
274 |
* |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
275 |
* <p> |
22141
6428b06e538b
8029895: XMLOutputFactory.newFactory(String, ClassLoader) - incorrect specification
joehw
parents:
21997
diff
changeset
|
276 |
* Note that this is a new method that replaces the deprecated |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
277 |
* {@link #newInstance(java.lang.String, java.lang.ClassLoader) |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
278 |
* newInstance(String factoryId, ClassLoader classLoader)} method. |
22141
6428b06e538b
8029895: XMLOutputFactory.newFactory(String, ClassLoader) - incorrect specification
joehw
parents:
21997
diff
changeset
|
279 |
* The original method was incorrectly defined to return XMLInputFactory. |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
280 |
* |
12005 | 281 |
* |
282 |
* @param factoryId Name of the factory to find, same as |
|
283 |
* a property name |
|
284 |
* @param classLoader classLoader to use |
|
285 |
* @return the factory implementation |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
286 |
* @throws FactoryConfigurationError in case of {@linkplain |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
287 |
* java.util.ServiceConfigurationError service configuration error} or if |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
288 |
* the implementation is not available or cannot be instantiated. |
12005 | 289 |
*/ |
290 |
public static XMLOutputFactory newFactory(String factoryId, |
|
291 |
ClassLoader classLoader) |
|
292 |
throws FactoryConfigurationError { |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
293 |
//do not fallback if given classloader can't find the class, throw exception |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
294 |
return FactoryFinder.find(XMLOutputFactory.class, factoryId, classLoader, null); |
12005 | 295 |
} |
296 |
||
297 |
/** |
|
298 |
* Create a new XMLStreamWriter that writes to a writer |
|
299 |
* @param stream the writer to write to |
|
300 |
* @throws XMLStreamException |
|
301 |
*/ |
|
302 |
public abstract XMLStreamWriter createXMLStreamWriter(java.io.Writer stream) throws XMLStreamException; |
|
303 |
||
304 |
/** |
|
305 |
* Create a new XMLStreamWriter that writes to a stream |
|
306 |
* @param stream the stream to write to |
|
307 |
* @throws XMLStreamException |
|
308 |
*/ |
|
309 |
public abstract XMLStreamWriter createXMLStreamWriter(java.io.OutputStream stream) throws XMLStreamException; |
|
310 |
||
311 |
/** |
|
312 |
* Create a new XMLStreamWriter that writes to a stream |
|
313 |
* @param stream the stream to write to |
|
314 |
* @param encoding the encoding to use |
|
315 |
* @throws XMLStreamException |
|
316 |
*/ |
|
317 |
public abstract XMLStreamWriter createXMLStreamWriter(java.io.OutputStream stream, |
|
318 |
String encoding) throws XMLStreamException; |
|
319 |
||
320 |
/** |
|
321 |
* Create a new XMLStreamWriter that writes to a JAXP result. This method is optional. |
|
322 |
* @param result the result to write to |
|
323 |
* @throws UnsupportedOperationException if this method is not |
|
324 |
* supported by this XMLOutputFactory |
|
325 |
* @throws XMLStreamException |
|
326 |
*/ |
|
327 |
public abstract XMLStreamWriter createXMLStreamWriter(Result result) throws XMLStreamException; |
|
328 |
||
329 |
||
330 |
/** |
|
331 |
* Create a new XMLEventWriter that writes to a JAXP result. This method is optional. |
|
332 |
* @param result the result to write to |
|
333 |
* @throws UnsupportedOperationException if this method is not |
|
334 |
* supported by this XMLOutputFactory |
|
335 |
* @throws XMLStreamException |
|
336 |
*/ |
|
337 |
public abstract XMLEventWriter createXMLEventWriter(Result result) throws XMLStreamException; |
|
338 |
||
339 |
/** |
|
340 |
* Create a new XMLEventWriter that writes to a stream |
|
341 |
* @param stream the stream to write to |
|
342 |
* @throws XMLStreamException |
|
343 |
*/ |
|
344 |
public abstract XMLEventWriter createXMLEventWriter(java.io.OutputStream stream) throws XMLStreamException; |
|
345 |
||
346 |
||
347 |
||
348 |
/** |
|
349 |
* Create a new XMLEventWriter that writes to a stream |
|
350 |
* @param stream the stream to write to |
|
351 |
* @param encoding the encoding to use |
|
352 |
* @throws XMLStreamException |
|
353 |
*/ |
|
354 |
public abstract XMLEventWriter createXMLEventWriter(java.io.OutputStream stream, |
|
355 |
String encoding) throws XMLStreamException; |
|
356 |
||
357 |
/** |
|
358 |
* Create a new XMLEventWriter that writes to a writer |
|
359 |
* @param stream the stream to write to |
|
360 |
* @throws XMLStreamException |
|
361 |
*/ |
|
362 |
public abstract XMLEventWriter createXMLEventWriter(java.io.Writer stream) throws XMLStreamException; |
|
363 |
||
364 |
/** |
|
365 |
* Allows the user to set specific features/properties on the underlying implementation. |
|
366 |
* @param name The name of the property |
|
367 |
* @param value The value of the property |
|
368 |
* @throws java.lang.IllegalArgumentException if the property is not supported |
|
369 |
*/ |
|
370 |
public abstract void setProperty(java.lang.String name, |
|
371 |
Object value) |
|
372 |
throws IllegalArgumentException; |
|
373 |
||
374 |
/** |
|
375 |
* Get a feature/property on the underlying implementation |
|
376 |
* @param name The name of the property |
|
377 |
* @return The value of the property |
|
378 |
* @throws java.lang.IllegalArgumentException if the property is not supported |
|
379 |
*/ |
|
380 |
public abstract Object getProperty(java.lang.String name) |
|
381 |
throws IllegalArgumentException; |
|
382 |
||
383 |
/** |
|
384 |
* Query the set of properties that this factory supports. |
|
385 |
* |
|
386 |
* @param name The name of the property (may not be null) |
|
387 |
* @return true if the property is supported and false otherwise |
|
388 |
*/ |
|
389 |
public abstract boolean isPropertySupported(String name); |
|
390 |
} |