author | joehw |
Fri, 24 Jan 2014 14:17:33 -0800 | |
changeset 22673 | 382d136fbba2 |
parent 21997 | 65d2e8e1d666 |
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 |
||
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
31 |
import javax.xml.stream.util.XMLEventAllocator; |
12005 | 32 |
import javax.xml.transform.Source; |
33 |
||
34 |
/** |
|
35 |
* Defines an abstract implementation of a factory for getting streams. |
|
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="5"> |
|
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> |
|
57 |
* <tr><td>javax.xml.stream.isValidating</td><td>Turns on/off implementation specific DTD validation</td><td>Boolean</td><td>False</td><td>No</td></tr> |
|
58 |
* <tr><td>javax.xml.stream.isNamespaceAware</td><td>Turns on/off namespace processing for XML 1.0 support</td><td>Boolean</td><td>True</td><td>True (required) / False (optional)</td></tr> |
|
59 |
* <tr><td>javax.xml.stream.isCoalescing</td><td>Requires the processor to coalesce adjacent character data</td><td>Boolean</td><td>False</td><td>Yes</td></tr> |
|
60 |
* <tr><td>javax.xml.stream.isReplacingEntityReferences</td><td>replace internal entity references with their replacement text and report them as characters</td><td>Boolean</td><td>True</td><td>Yes</td></tr> |
|
61 |
*<tr><td>javax.xml.stream.isSupportingExternalEntities</td><td>Resolve external parsed entities</td><td>Boolean</td><td>Unspecified</td><td>Yes</td></tr> |
|
62 |
*<tr><td>javax.xml.stream.supportDTD</td><td>Use this property to request processors that do not support DTDs</td><td>Boolean</td><td>True</td><td>Yes</td></tr> |
|
63 |
*<tr><td>javax.xml.stream.reporter</td><td>sets/gets the impl of the XMLReporter </td><td>javax.xml.stream.XMLReporter</td><td>Null</td><td>Yes</td></tr> |
|
64 |
*<tr><td>javax.xml.stream.resolver</td><td>sets/gets the impl of the XMLResolver interface</td><td>javax.xml.stream.XMLResolver</td><td>Null</td><td>Yes</td></tr> |
|
65 |
*<tr><td>javax.xml.stream.allocator</td><td>sets/gets the impl of the XMLEventAllocator interface</td><td>javax.xml.stream.util.XMLEventAllocator</td><td>Null</td><td>Yes</td></tr> |
|
66 |
* </tbody> |
|
67 |
* </table> |
|
68 |
* |
|
69 |
* |
|
70 |
* @version 1.2 |
|
71 |
* @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved. |
|
72 |
* @see XMLOutputFactory |
|
73 |
* @see XMLEventReader |
|
74 |
* @see XMLStreamReader |
|
75 |
* @see EventFilter |
|
76 |
* @see XMLReporter |
|
77 |
* @see XMLResolver |
|
78 |
* @see javax.xml.stream.util.XMLEventAllocator |
|
79 |
* @since 1.6 |
|
80 |
*/ |
|
81 |
||
82 |
public abstract class XMLInputFactory { |
|
83 |
/** |
|
84 |
* The property used to turn on/off namespace support, |
|
85 |
* this is to support XML 1.0 documents, |
|
86 |
* only the true setting must be supported |
|
87 |
*/ |
|
88 |
public static final String IS_NAMESPACE_AWARE= |
|
89 |
"javax.xml.stream.isNamespaceAware"; |
|
90 |
||
91 |
/** |
|
92 |
* The property used to turn on/off implementation specific validation |
|
93 |
*/ |
|
94 |
public static final String IS_VALIDATING= |
|
95 |
"javax.xml.stream.isValidating"; |
|
96 |
||
97 |
/** |
|
98 |
* The property that requires the parser to coalesce adjacent character data sections |
|
99 |
*/ |
|
100 |
public static final String IS_COALESCING= |
|
101 |
"javax.xml.stream.isCoalescing"; |
|
102 |
||
103 |
/** |
|
104 |
* Requires the parser to replace internal |
|
105 |
* entity references with their replacement |
|
106 |
* text and report them as characters |
|
107 |
*/ |
|
108 |
public static final String IS_REPLACING_ENTITY_REFERENCES= |
|
109 |
"javax.xml.stream.isReplacingEntityReferences"; |
|
110 |
||
111 |
/** |
|
112 |
* The property that requires the parser to resolve external parsed entities |
|
113 |
*/ |
|
114 |
public static final String IS_SUPPORTING_EXTERNAL_ENTITIES= |
|
115 |
"javax.xml.stream.isSupportingExternalEntities"; |
|
116 |
||
117 |
/** |
|
118 |
* The property that requires the parser to support DTDs |
|
119 |
*/ |
|
120 |
public static final String SUPPORT_DTD= |
|
121 |
"javax.xml.stream.supportDTD"; |
|
122 |
||
123 |
/** |
|
124 |
* The property used to |
|
125 |
* set/get the implementation of the XMLReporter interface |
|
126 |
*/ |
|
127 |
public static final String REPORTER= |
|
128 |
"javax.xml.stream.reporter"; |
|
129 |
||
130 |
/** |
|
131 |
* The property used to set/get the implementation of the XMLResolver |
|
132 |
*/ |
|
133 |
public static final String RESOLVER= |
|
134 |
"javax.xml.stream.resolver"; |
|
135 |
||
136 |
/** |
|
137 |
* The property used to set/get the implementation of the allocator |
|
138 |
*/ |
|
139 |
public static final String ALLOCATOR= |
|
140 |
"javax.xml.stream.allocator"; |
|
141 |
||
142 |
static final String DEFAULIMPL = "com.sun.xml.internal.stream.XMLInputFactoryImpl"; |
|
143 |
||
144 |
protected XMLInputFactory(){} |
|
145 |
||
146 |
/** |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
147 |
* 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
|
148 |
* {@link #newFactory()} method. |
12005 | 149 |
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded |
150 |
*/ |
|
151 |
public static XMLInputFactory newInstance() |
|
152 |
throws FactoryConfigurationError |
|
153 |
{ |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
154 |
return FactoryFinder.find(XMLInputFactory.class, DEFAULIMPL); |
12005 | 155 |
} |
156 |
||
157 |
/** |
|
158 |
* Create a new instance of the factory. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
159 |
* <p> |
12005 | 160 |
* This static method creates a new factory instance. |
161 |
* This method uses the following ordered lookup procedure to determine |
|
162 |
* the XMLInputFactory implementation class to load: |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
163 |
* </p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
164 |
* <ul> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
165 |
* <li> |
12005 | 166 |
* Use the javax.xml.stream.XMLInputFactory system property. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
167 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
168 |
* <li> |
12005 | 169 |
* Use the properties file "lib/stax.properties" in the JRE directory. |
170 |
* This configuration file is in standard java.util.Properties format |
|
171 |
* and contains the fully qualified name of the implementation class |
|
172 |
* with the key being the system property defined above. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
173 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
174 |
* <li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
175 |
* Use the service-provider loading facilities, defined by the |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
176 |
* {@link java.util.ServiceLoader} class, to attempt to locate and load an |
20581
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
177 |
* implementation of the service using the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
178 |
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}: |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
179 |
* the service-provider loading facility will use the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
180 |
* java.lang.Thread#getContextClassLoader() current thread's context class loader} |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
181 |
* to attempt to load the service. If the context class |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
182 |
* loader is null, the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
183 |
* ClassLoader#getSystemClassLoader() system class loader} will be used. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
184 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
185 |
* <li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
186 |
* Otherwise, the system-default implementation is returned. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
187 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
188 |
* </ul> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
189 |
* <p> |
12005 | 190 |
* Once an application has obtained a reference to a XMLInputFactory it |
191 |
* 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
|
192 |
* </p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
193 |
* <p> |
12005 | 194 |
* Note that this is a new method that replaces the deprecated newInstance() method. |
195 |
* No changes in behavior are defined by this replacement method relative to |
|
196 |
* the deprecated method. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
197 |
* </p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
198 |
* @throws FactoryConfigurationError in case of {@linkplain |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
199 |
* java.util.ServiceConfigurationError service configuration error} or if |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
200 |
* the implementation is not available or cannot be instantiated. |
12005 | 201 |
*/ |
202 |
public static XMLInputFactory newFactory() |
|
203 |
throws FactoryConfigurationError |
|
204 |
{ |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
205 |
return FactoryFinder.find(XMLInputFactory.class, DEFAULIMPL); |
12005 | 206 |
} |
207 |
||
208 |
/** |
|
209 |
* Create a new instance of the factory |
|
210 |
* |
|
211 |
* @param factoryId Name of the factory to find, same as |
|
212 |
* a property name |
|
213 |
* @param classLoader classLoader to use |
|
214 |
* @return the factory implementation |
|
215 |
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded |
|
216 |
* |
|
217 |
* @deprecated This method has been deprecated to maintain API consistency. |
|
218 |
* All newInstance methods have been replaced with corresponding |
|
219 |
* newFactory methods. The replacement {@link |
|
220 |
* #newFactory(java.lang.String, java.lang.ClassLoader)} method |
|
221 |
* defines no changes in behavior. |
|
222 |
*/ |
|
223 |
public static XMLInputFactory newInstance(String factoryId, |
|
224 |
ClassLoader classLoader) |
|
225 |
throws FactoryConfigurationError { |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
226 |
//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
|
227 |
return FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null); |
12005 | 228 |
} |
229 |
||
230 |
/** |
|
231 |
* Create a new instance of the factory. |
|
232 |
* 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
|
233 |
* <p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
234 |
* 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
|
235 |
* the XMLInputFactory implementation class to load: |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
236 |
* </p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
237 |
* <ul> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
238 |
* <li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
239 |
* 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
|
240 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
241 |
* <li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
242 |
* Use the properties file "lib/stax.properties" in the JRE directory. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
243 |
* This configuration file is in standard java.util.Properties format |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
244 |
* and contains the fully qualified name of the implementation class |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
245 |
* with the key being the given {@code factoryId}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
246 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
247 |
* <li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
248 |
* If {@code factoryId} is "javax.xml.stream.XMLInputFactory", |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
249 |
* use the service-provider loading facilities, defined by the |
22673
382d136fbba2
8032392: Spec: javax.xml.stream.XMLEventFactory/XMLOutputFactory/XMLInputFactory.newFactory(String, ClassLoader) referring to ServiceLoader.load(Class, ClassLoader)
joehw
parents:
21997
diff
changeset
|
250 |
* {@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:
21997
diff
changeset
|
251 |
* 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:
21997
diff
changeset
|
252 |
* 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
|
253 |
* 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
|
254 |
* 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
|
255 |
* That is, the service-provider loading facility will use the {@linkplain |
20581
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
256 |
* java.lang.Thread#getContextClassLoader() current thread's context class loader} |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
257 |
* to attempt to load the service. If the context class |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
258 |
* loader is null, the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17537
diff
changeset
|
259 |
* ClassLoader#getSystemClassLoader() system class loader} will be used. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
260 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
261 |
* <li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
262 |
* Otherwise, throws a {@link FactoryConfigurationError}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
263 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
264 |
* </ul> |
12005 | 265 |
* |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
266 |
* <p> |
12005 | 267 |
* 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
|
268 |
* {@link #newInstance(java.lang.String, java.lang.ClassLoader) |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
269 |
* newInstance(String factoryId, ClassLoader classLoader)} method. |
12005 | 270 |
* No changes in behavior are defined by this replacement method relative |
271 |
* to the deprecated method. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
272 |
* </p> |
12005 | 273 |
* |
21997
65d2e8e1d666
8027973: Error in the documentation for newFactory method of the javax.xml.stream factories
joehw
parents:
20581
diff
changeset
|
274 |
* @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
|
275 |
* 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
|
276 |
* 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
|
277 |
* |
12005 | 278 |
* @param factoryId Name of the factory to find, same as |
279 |
* a property name |
|
280 |
* @param classLoader classLoader to use |
|
281 |
* @return the factory implementation |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
282 |
* @throws FactoryConfigurationError in case of {@linkplain |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
283 |
* java.util.ServiceConfigurationError service configuration error} or if |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
284 |
* the implementation is not available or cannot be instantiated. |
12005 | 285 |
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded |
286 |
*/ |
|
287 |
public static XMLInputFactory newFactory(String factoryId, |
|
288 |
ClassLoader classLoader) |
|
289 |
throws FactoryConfigurationError { |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
12457
diff
changeset
|
290 |
//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
|
291 |
return FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null); |
12005 | 292 |
} |
293 |
||
294 |
/** |
|
295 |
* Create a new XMLStreamReader from a reader |
|
296 |
* @param reader the XML data to read from |
|
297 |
* @throws XMLStreamException |
|
298 |
*/ |
|
299 |
public abstract XMLStreamReader createXMLStreamReader(java.io.Reader reader) |
|
300 |
throws XMLStreamException; |
|
301 |
||
302 |
/** |
|
303 |
* Create a new XMLStreamReader from a JAXP source. This method is optional. |
|
304 |
* @param source the source to read from |
|
305 |
* @throws UnsupportedOperationException if this method is not |
|
306 |
* supported by this XMLInputFactory |
|
307 |
* @throws XMLStreamException |
|
308 |
*/ |
|
309 |
public abstract XMLStreamReader createXMLStreamReader(Source source) |
|
310 |
throws XMLStreamException; |
|
311 |
||
312 |
/** |
|
313 |
* Create a new XMLStreamReader from a java.io.InputStream |
|
314 |
* @param stream the InputStream to read from |
|
315 |
* @throws XMLStreamException |
|
316 |
*/ |
|
317 |
public abstract XMLStreamReader createXMLStreamReader(java.io.InputStream stream) |
|
318 |
throws XMLStreamException; |
|
319 |
||
320 |
/** |
|
321 |
* Create a new XMLStreamReader from a java.io.InputStream |
|
322 |
* @param stream the InputStream to read from |
|
323 |
* @param encoding the character encoding of the stream |
|
324 |
* @throws XMLStreamException |
|
325 |
*/ |
|
326 |
public abstract XMLStreamReader createXMLStreamReader(java.io.InputStream stream, String encoding) |
|
327 |
throws XMLStreamException; |
|
328 |
||
329 |
/** |
|
330 |
* Create a new XMLStreamReader from a java.io.InputStream |
|
331 |
* @param systemId the system ID of the stream |
|
332 |
* @param stream the InputStream to read from |
|
333 |
*/ |
|
334 |
public abstract XMLStreamReader createXMLStreamReader(String systemId, java.io.InputStream stream) |
|
335 |
throws XMLStreamException; |
|
336 |
||
337 |
/** |
|
338 |
* Create a new XMLStreamReader from a java.io.InputStream |
|
339 |
* @param systemId the system ID of the stream |
|
340 |
* @param reader the InputStream to read from |
|
341 |
*/ |
|
342 |
public abstract XMLStreamReader createXMLStreamReader(String systemId, java.io.Reader reader) |
|
343 |
throws XMLStreamException; |
|
344 |
||
345 |
/** |
|
346 |
* Create a new XMLEventReader from a reader |
|
347 |
* @param reader the XML data to read from |
|
348 |
* @throws XMLStreamException |
|
349 |
*/ |
|
350 |
public abstract XMLEventReader createXMLEventReader(java.io.Reader reader) |
|
351 |
throws XMLStreamException; |
|
352 |
||
353 |
/** |
|
354 |
* Create a new XMLEventReader from a reader |
|
355 |
* @param systemId the system ID of the input |
|
356 |
* @param reader the XML data to read from |
|
357 |
* @throws XMLStreamException |
|
358 |
*/ |
|
359 |
public abstract XMLEventReader createXMLEventReader(String systemId, java.io.Reader reader) |
|
360 |
throws XMLStreamException; |
|
361 |
||
362 |
/** |
|
363 |
* Create a new XMLEventReader from an XMLStreamReader. After being used |
|
364 |
* to construct the XMLEventReader instance returned from this method |
|
365 |
* the XMLStreamReader must not be used. |
|
366 |
* @param reader the XMLStreamReader to read from (may not be modified) |
|
367 |
* @return a new XMLEventReader |
|
368 |
* @throws XMLStreamException |
|
369 |
*/ |
|
370 |
public abstract XMLEventReader createXMLEventReader(XMLStreamReader reader) |
|
371 |
throws XMLStreamException; |
|
372 |
||
373 |
/** |
|
374 |
* Create a new XMLEventReader from a JAXP source. |
|
375 |
* Support of this method is optional. |
|
376 |
* @param source the source to read from |
|
377 |
* @throws UnsupportedOperationException if this method is not |
|
378 |
* supported by this XMLInputFactory |
|
379 |
*/ |
|
380 |
public abstract XMLEventReader createXMLEventReader(Source source) |
|
381 |
throws XMLStreamException; |
|
382 |
||
383 |
/** |
|
384 |
* Create a new XMLEventReader from a java.io.InputStream |
|
385 |
* @param stream the InputStream to read from |
|
386 |
* @throws XMLStreamException |
|
387 |
*/ |
|
388 |
public abstract XMLEventReader createXMLEventReader(java.io.InputStream stream) |
|
389 |
throws XMLStreamException; |
|
390 |
||
391 |
/** |
|
392 |
* Create a new XMLEventReader from a java.io.InputStream |
|
393 |
* @param stream the InputStream to read from |
|
394 |
* @param encoding the character encoding of the stream |
|
395 |
* @throws XMLStreamException |
|
396 |
*/ |
|
397 |
public abstract XMLEventReader createXMLEventReader(java.io.InputStream stream, String encoding) |
|
398 |
throws XMLStreamException; |
|
399 |
||
400 |
/** |
|
401 |
* Create a new XMLEventReader from a java.io.InputStream |
|
402 |
* @param systemId the system ID of the stream |
|
403 |
* @param stream the InputStream to read from |
|
404 |
* @throws XMLStreamException |
|
405 |
*/ |
|
406 |
public abstract XMLEventReader createXMLEventReader(String systemId, java.io.InputStream stream) |
|
407 |
throws XMLStreamException; |
|
408 |
||
409 |
/** |
|
410 |
* Create a filtered reader that wraps the filter around the reader |
|
411 |
* @param reader the reader to filter |
|
412 |
* @param filter the filter to apply to the reader |
|
413 |
* @throws XMLStreamException |
|
414 |
*/ |
|
415 |
public abstract XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) |
|
416 |
throws XMLStreamException; |
|
417 |
||
418 |
/** |
|
419 |
* Create a filtered event reader that wraps the filter around the event reader |
|
420 |
* @param reader the event reader to wrap |
|
421 |
* @param filter the filter to apply to the event reader |
|
422 |
* @throws XMLStreamException |
|
423 |
*/ |
|
424 |
public abstract XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) |
|
425 |
throws XMLStreamException; |
|
426 |
||
427 |
/** |
|
428 |
* The resolver that will be set on any XMLStreamReader or XMLEventReader created |
|
429 |
* by this factory instance. |
|
430 |
*/ |
|
431 |
public abstract XMLResolver getXMLResolver(); |
|
432 |
||
433 |
/** |
|
434 |
* The resolver that will be set on any XMLStreamReader or XMLEventReader created |
|
435 |
* by this factory instance. |
|
436 |
* @param resolver the resolver to use to resolve references |
|
437 |
*/ |
|
438 |
public abstract void setXMLResolver(XMLResolver resolver); |
|
439 |
||
440 |
/** |
|
441 |
* The reporter that will be set on any XMLStreamReader or XMLEventReader created |
|
442 |
* by this factory instance. |
|
443 |
*/ |
|
444 |
public abstract XMLReporter getXMLReporter(); |
|
445 |
||
446 |
/** |
|
447 |
* The reporter that will be set on any XMLStreamReader or XMLEventReader created |
|
448 |
* by this factory instance. |
|
449 |
* @param reporter the resolver to use to report non fatal errors |
|
450 |
*/ |
|
451 |
public abstract void setXMLReporter(XMLReporter reporter); |
|
452 |
||
453 |
/** |
|
17534 | 454 |
* Allows the user to set specific feature/property on the underlying |
455 |
* implementation. The underlying implementation is not required to support |
|
456 |
* every setting of every property in the specification and may use |
|
457 |
* IllegalArgumentException to signal that an unsupported property may not be |
|
458 |
* set with the specified value. |
|
459 |
* <p> |
|
460 |
* All implementations that implement JAXP 1.5 or newer are required to |
|
461 |
* support the {@link javax.xml.XMLConstants#ACCESS_EXTERNAL_DTD} property. |
|
462 |
* </p> |
|
463 |
* <ul> |
|
464 |
* <li> |
|
465 |
* <p> |
|
466 |
* Access to external DTDs, external Entity References is restricted to the |
|
467 |
* protocols specified by the property. If access is denied during parsing |
|
468 |
* due to the restriction of this property, {@link javax.xml.stream.XMLStreamException} |
|
17537 | 469 |
* will be thrown by the {@link javax.xml.stream.XMLStreamReader#next()} or |
470 |
* {@link javax.xml.stream.XMLEventReader#nextEvent()} method. |
|
17534 | 471 |
* </p> |
472 |
* </li> |
|
473 |
* </ul> |
|
12005 | 474 |
* @param name The name of the property (may not be null) |
475 |
* @param value The value of the property |
|
476 |
* @throws java.lang.IllegalArgumentException if the property is not supported |
|
477 |
*/ |
|
478 |
public abstract void setProperty(java.lang.String name, Object value) |
|
479 |
throws java.lang.IllegalArgumentException; |
|
480 |
||
481 |
/** |
|
482 |
* Get the value of a feature/property from the underlying implementation |
|
483 |
* @param name The name of the property (may not be null) |
|
484 |
* @return The value of the property |
|
485 |
* @throws IllegalArgumentException if the property is not supported |
|
486 |
*/ |
|
487 |
public abstract Object getProperty(java.lang.String name) |
|
488 |
throws java.lang.IllegalArgumentException; |
|
489 |
||
490 |
||
491 |
/** |
|
492 |
* Query the set of properties that this factory supports. |
|
493 |
* |
|
494 |
* @param name The name of the property (may not be null) |
|
495 |
* @return true if the property is supported and false otherwise |
|
496 |
*/ |
|
497 |
public abstract boolean isPropertySupported(String name); |
|
498 |
||
499 |
/** |
|
500 |
* Set a user defined event allocator for events |
|
501 |
* @param allocator the user defined allocator |
|
502 |
*/ |
|
503 |
public abstract void setEventAllocator(XMLEventAllocator allocator); |
|
504 |
||
505 |
/** |
|
506 |
* Gets the allocator used by streams created with this factory |
|
507 |
*/ |
|
508 |
public abstract XMLEventAllocator getEventAllocator(); |
|
509 |
||
510 |
} |