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 /*
26 * Copyright (c) 2009, 2013, by Oracle Corporation. All Rights Reserved.
27 */
28
29 package javax.xml.stream;
30
31 import com.sun.xml.internal.stream.XMLInputFactoryImpl;
32 import javax.xml.stream.util.XMLEventAllocator;
33 import javax.xml.transform.Source;
34
35 /**
36 * Defines an abstract implementation of a factory for getting streams.
37 *
38 * The following table defines the standard properties of this specification.
39 * Each property varies in the level of support required by each implementation.
40 * The level of support required is described in the 'Required' column.
41 *
42 * <table border="2" rules="all" cellpadding="4">
43 * <thead>
44 * <tr>
45 * <th align="center" colspan="5">
46 * Configuration parameters
47 * </th>
48 * </tr>
208 * loader is null, the {@linkplain
209 * ClassLoader#getSystemClassLoader() system class loader} will be used.
210 * </li>
211 * <li>
212 * <p>Otherwise, the {@linkplain #newDefaultFactory() system-default}
213 * implementation is returned.
214 * </li>
215 * </ul>
216 * <p>
217 * Once an application has obtained a reference to a XMLInputFactory it
218 * can use the factory to configure and obtain stream instances.
219 * <p>
220 * Note that this is a new method that replaces the deprecated newInstance() method.
221 * No changes in behavior are defined by this replacement method relative to
222 * the deprecated method.
223 *
224 * @throws FactoryConfigurationError in case of {@linkplain
225 * java.util.ServiceConfigurationError service configuration error} or if
226 * the implementation is not available or cannot be instantiated.
227 */
228 public static XMLInputFactory newFactory()
229 throws FactoryConfigurationError
230 {
231 return FactoryFinder.find(XMLInputFactory.class, DEFAULIMPL);
232 }
233
234 /**
235 * Create a new instance of the factory
236 *
237 * @param factoryId Name of the factory to find, same as
238 * a property name
239 * @param classLoader classLoader to use
240 * @return the factory implementation
241 * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
242 *
243 * @deprecated This method has been deprecated to maintain API consistency.
244 * All newInstance methods have been replaced with corresponding
245 * newFactory methods. The replacement {@link
246 * #newFactory(java.lang.String, java.lang.ClassLoader)} method
247 * defines no changes in behavior.
248 */
249 public static XMLInputFactory newInstance(String factoryId,
250 ClassLoader classLoader)
251 throws FactoryConfigurationError {
252 //do not fallback if given classloader can't find the class, throw exception
253 return FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null);
254 }
255
256 /**
257 * Create a new instance of the factory.
258 * If the classLoader argument is null, then the ContextClassLoader is used.
259 * <p>
260 * This method uses the following ordered lookup procedure to determine
261 * the XMLInputFactory implementation class to load:
262 * <ul>
263 * <li>
264 * <p>
265 * Use the value of the system property identified by {@code factoryId}.
266 * </li>
267 * <li>
268 * <p>
|
1 /*
2 * Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
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.stream;
27
28 import com.sun.xml.internal.stream.XMLInputFactoryImpl;
29 import javax.xml.stream.util.XMLEventAllocator;
30 import javax.xml.transform.Source;
31
32 /**
33 * Defines an abstract implementation of a factory for getting streams.
34 *
35 * The following table defines the standard properties of this specification.
36 * Each property varies in the level of support required by each implementation.
37 * The level of support required is described in the 'Required' column.
38 *
39 * <table border="2" rules="all" cellpadding="4">
40 * <thead>
41 * <tr>
42 * <th align="center" colspan="5">
43 * Configuration parameters
44 * </th>
45 * </tr>
205 * loader is null, the {@linkplain
206 * ClassLoader#getSystemClassLoader() system class loader} will be used.
207 * </li>
208 * <li>
209 * <p>Otherwise, the {@linkplain #newDefaultFactory() system-default}
210 * implementation is returned.
211 * </li>
212 * </ul>
213 * <p>
214 * Once an application has obtained a reference to a XMLInputFactory it
215 * can use the factory to configure and obtain stream instances.
216 * <p>
217 * Note that this is a new method that replaces the deprecated newInstance() method.
218 * No changes in behavior are defined by this replacement method relative to
219 * the deprecated method.
220 *
221 * @throws FactoryConfigurationError in case of {@linkplain
222 * java.util.ServiceConfigurationError service configuration error} or if
223 * the implementation is not available or cannot be instantiated.
224 */
225 @Deprecated(since="7")
226 public static XMLInputFactory newFactory()
227 throws FactoryConfigurationError
228 {
229 return FactoryFinder.find(XMLInputFactory.class, DEFAULIMPL);
230 }
231
232 /**
233 * Create a new instance of the factory
234 *
235 * @param factoryId Name of the factory to find, same as
236 * a property name
237 * @param classLoader classLoader to use
238 * @return the factory implementation
239 * @throws FactoryConfigurationError if an instance of this factory cannot be loaded
240 *
241 * @deprecated This method has been deprecated to maintain API consistency.
242 * All newInstance methods have been replaced with corresponding
243 * newFactory methods. The replacement {@link
244 * #newFactory(java.lang.String, java.lang.ClassLoader)} method
245 * defines no changes in behavior.
246 */
247 @Deprecated(since="7")
248 public static XMLInputFactory newInstance(String factoryId,
249 ClassLoader classLoader)
250 throws FactoryConfigurationError {
251 //do not fallback if given classloader can't find the class, throw exception
252 return FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null);
253 }
254
255 /**
256 * Create a new instance of the factory.
257 * If the classLoader argument is null, then the ContextClassLoader is used.
258 * <p>
259 * This method uses the following ordered lookup procedure to determine
260 * the XMLInputFactory implementation class to load:
261 * <ul>
262 * <li>
263 * <p>
264 * Use the value of the system property identified by {@code factoryId}.
265 * </li>
266 * <li>
267 * <p>
|