author | ctornqvi |
Thu, 23 Apr 2015 12:47:23 -0700 | |
changeset 30286 | 7e076dc01291 |
parent 29419 | 534054ee6062 |
child 29999 | 8493f5fc1052 |
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 |
/* |
|
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
26 |
* Copyright (c) 2009, 2015, by Oracle Corporation. All Rights Reserved. |
12005 | 27 |
*/ |
28 |
||
29 |
package javax.xml.stream; |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
30 |
import java.util.Iterator; |
12005 | 31 |
import javax.xml.namespace.NamespaceContext; |
32 |
import javax.xml.namespace.QName; |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
33 |
import javax.xml.stream.events.*; |
12005 | 34 |
/** |
35 |
* This interface defines a utility class for creating instances of |
|
36 |
* XMLEvents |
|
37 |
* @version 1.2 |
|
38 |
* @author Copyright (c) 2009 by Oracle Corporation. All Rights Reserved. |
|
39 |
* @see javax.xml.stream.events.StartElement |
|
40 |
* @see javax.xml.stream.events.EndElement |
|
41 |
* @see javax.xml.stream.events.ProcessingInstruction |
|
42 |
* @see javax.xml.stream.events.Comment |
|
43 |
* @see javax.xml.stream.events.Characters |
|
44 |
* @see javax.xml.stream.events.StartDocument |
|
45 |
* @see javax.xml.stream.events.EndDocument |
|
46 |
* @see javax.xml.stream.events.DTD |
|
47 |
* @since 1.6 |
|
48 |
*/ |
|
49 |
public abstract class XMLEventFactory { |
|
50 |
protected XMLEventFactory(){} |
|
51 |
||
13624
56ea3a894b56
7191547: XMLEventFactory.newFactory(String factoryId, ClassLoader loader) does not work as expected
joehw
parents:
12457
diff
changeset
|
52 |
static final String JAXPFACTORYID = "javax.xml.stream.XMLEventFactory"; |
56ea3a894b56
7191547: XMLEventFactory.newFactory(String factoryId, ClassLoader loader) does not work as expected
joehw
parents:
12457
diff
changeset
|
53 |
static final String DEFAULIMPL = "com.sun.xml.internal.stream.events.XMLEventFactoryImpl"; |
56ea3a894b56
7191547: XMLEventFactory.newFactory(String factoryId, ClassLoader loader) does not work as expected
joehw
parents:
12457
diff
changeset
|
54 |
|
56ea3a894b56
7191547: XMLEventFactory.newFactory(String factoryId, ClassLoader loader) does not work as expected
joehw
parents:
12457
diff
changeset
|
55 |
|
12005 | 56 |
/** |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
57 |
* 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:
13624
diff
changeset
|
58 |
* {@link #newFactory()} method. |
12005 | 59 |
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded |
60 |
*/ |
|
61 |
public static XMLEventFactory newInstance() |
|
62 |
throws FactoryConfigurationError |
|
63 |
{ |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
64 |
return FactoryFinder.find(XMLEventFactory.class, DEFAULIMPL); |
12005 | 65 |
} |
66 |
||
67 |
/** |
|
68 |
* Create a new instance of the factory. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
69 |
* <p> |
12005 | 70 |
* This static method creates a new factory instance. |
71 |
* This method uses the following ordered lookup procedure to determine |
|
72 |
* the XMLEventFactory implementation class to load: |
|
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
73 |
* <p> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
74 |
* <ul> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
75 |
* <li> |
12005 | 76 |
* Use the javax.xml.stream.XMLEventFactory system property. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
77 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
78 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
79 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
80 |
* 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
|
81 |
* {@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
|
82 |
* {@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
|
83 |
* 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
|
84 |
* defined above. |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
85 |
* |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
86 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
87 |
* 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
|
88 |
* 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
|
89 |
* 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
|
90 |
* 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
|
91 |
* 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
|
92 |
* |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
93 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
94 |
* 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
|
95 |
* 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
|
96 |
* not exist. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
97 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
98 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
99 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
100 |
* Use the service-provider loading facility, defined by the |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
101 |
* {@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
|
102 |
* implementation of the service using the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
103 |
* java.util.ServiceLoader#load(java.lang.Class) default loading mechanism}: |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
104 |
* the service-provider loading facility will use the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
105 |
* java.lang.Thread#getContextClassLoader() current thread's context class loader} |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
106 |
* to attempt to load the service. If the context class |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
107 |
* loader is null, the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
108 |
* ClassLoader#getSystemClassLoader() system class loader} will be used. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
109 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
110 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
111 |
* <p> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
112 |
* Otherwise, the system-default implementation is returned. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
113 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
114 |
* </ul> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
115 |
* <p> |
12005 | 116 |
* Once an application has obtained a reference to a XMLEventFactory it |
117 |
* can use the factory to configure and obtain stream instances. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
118 |
* <p> |
12005 | 119 |
* Note that this is a new method that replaces the deprecated newInstance() method. |
120 |
* No changes in behavior are defined by this replacement method relative to |
|
121 |
* the deprecated method. |
|
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
122 |
* |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
123 |
* @throws FactoryConfigurationError in case of {@linkplain |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
124 |
* java.util.ServiceConfigurationError service configuration error} or if |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
125 |
* the implementation is not available or cannot be instantiated. |
12005 | 126 |
*/ |
127 |
public static XMLEventFactory newFactory() |
|
128 |
throws FactoryConfigurationError |
|
129 |
{ |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
130 |
return FactoryFinder.find(XMLEventFactory.class, DEFAULIMPL); |
12005 | 131 |
} |
132 |
||
133 |
/** |
|
134 |
* Create a new instance of the factory |
|
135 |
* |
|
136 |
* @param factoryId Name of the factory to find, same as |
|
137 |
* a property name |
|
138 |
* @param classLoader classLoader to use |
|
139 |
* @return the factory implementation |
|
140 |
* @throws FactoryConfigurationError if an instance of this factory cannot be loaded |
|
141 |
* |
|
142 |
* @deprecated This method has been deprecated to maintain API consistency. |
|
143 |
* All newInstance methods have been replaced with corresponding |
|
144 |
* newFactory methods. The replacement {@link |
|
145 |
* #newFactory(java.lang.String, java.lang.ClassLoader)} |
|
146 |
* method defines no changes in behavior. |
|
147 |
*/ |
|
148 |
public static XMLEventFactory newInstance(String factoryId, |
|
149 |
ClassLoader classLoader) |
|
150 |
throws FactoryConfigurationError { |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
151 |
//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:
13624
diff
changeset
|
152 |
return FactoryFinder.find(XMLEventFactory.class, factoryId, classLoader, null); |
12005 | 153 |
} |
154 |
||
155 |
/** |
|
156 |
* Create a new instance of the factory. |
|
157 |
* If the classLoader argument is null, then the ContextClassLoader is used. |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
158 |
* <p> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
159 |
* This method uses the following ordered lookup procedure to determine |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
160 |
* the XMLEventFactory implementation class to load: |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
161 |
* <p> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
162 |
* <ul> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
163 |
* <li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
164 |
* Use the value of the system property identified by {@code factoryId}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
165 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
166 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
167 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
168 |
* 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
|
169 |
* {@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
|
170 |
* 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
|
171 |
* 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
|
172 |
* defined above. |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
173 |
* |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
174 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
175 |
* 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
|
176 |
* 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
|
177 |
* 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
|
178 |
* 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
|
179 |
* 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
|
180 |
* |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
181 |
* <p> |
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
182 |
* 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
|
183 |
* 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
|
184 |
* not exist. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
185 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
186 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
187 |
* <p> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
188 |
* If {@code factoryId} is "javax.xml.stream.XMLEventFactory", |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
189 |
* 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:
21997
diff
changeset
|
190 |
* {@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
|
191 |
* 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
|
192 |
* 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
|
193 |
* 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
|
194 |
* 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
|
195 |
* 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
|
196 |
* java.lang.Thread#getContextClassLoader() current thread's context class loader} |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
197 |
* to attempt to load the service. If the context class |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
198 |
* loader is null, the {@linkplain |
65d17ea72da3
8025745: Clarify API documentation of JAXP factories.
dfuchs
parents:
17264
diff
changeset
|
199 |
* ClassLoader#getSystemClassLoader() system class loader} will be used. |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
200 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
201 |
* <li> |
29419
534054ee6062
8049378: Examine references to ${java.home}/lib in JAXP
joehw
parents:
25868
diff
changeset
|
202 |
* <p> |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
203 |
* Otherwise, throws a {@link FactoryConfigurationError}. |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
204 |
* </li> |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
205 |
* </ul> |
12005 | 206 |
* |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
207 |
* <p> |
12005 | 208 |
* Note that this is a new method that replaces the deprecated |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
209 |
* {@link #newInstance(java.lang.String, java.lang.ClassLoader) |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
210 |
* newInstance(String factoryId, ClassLoader classLoader)} method. |
12005 | 211 |
* No changes in behavior are defined by this replacement method relative |
212 |
* to the deprecated method. |
|
213 |
* |
|
21997
65d2e8e1d666
8027973: Error in the documentation for newFactory method of the javax.xml.stream factories
joehw
parents:
20581
diff
changeset
|
214 |
* @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
|
215 |
* 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
|
216 |
* 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
|
217 |
* |
12005 | 218 |
* @param factoryId Name of the factory to find, same as |
219 |
* a property name |
|
220 |
* @param classLoader classLoader to use |
|
221 |
* @return the factory implementation |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
222 |
* @throws FactoryConfigurationError in case of {@linkplain |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
223 |
* java.util.ServiceConfigurationError service configuration error} or if |
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
224 |
* the implementation is not available or cannot be instantiated. |
12005 | 225 |
*/ |
226 |
public static XMLEventFactory newFactory(String factoryId, |
|
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
227 |
ClassLoader classLoader) |
12005 | 228 |
throws FactoryConfigurationError { |
17264
3aff554ad461
8005954: JAXP Plugability Layer should use java.util.ServiceLoader
dfuchs
parents:
13624
diff
changeset
|
229 |
//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:
13624
diff
changeset
|
230 |
return FactoryFinder.find(XMLEventFactory.class, factoryId, classLoader, null); |
12005 | 231 |
} |
232 |
||
233 |
/** |
|
234 |
* This method allows setting of the Location on each event that |
|
235 |
* is created by this factory. The values are copied by value into |
|
236 |
* the events created by this factory. To reset the location |
|
237 |
* information set the location to null. |
|
238 |
* @param location the location to set on each event created |
|
239 |
*/ |
|
240 |
public abstract void setLocation(Location location); |
|
241 |
||
242 |
/** |
|
243 |
* Create a new Attribute |
|
244 |
* @param prefix the prefix of this attribute, may not be null |
|
245 |
* @param namespaceURI the attribute value is set to this value, may not be null |
|
246 |
* @param localName the local name of the XML name of the attribute, localName cannot be null |
|
247 |
* @param value the attribute value to set, may not be null |
|
248 |
* @return the Attribute with specified values |
|
249 |
*/ |
|
250 |
public abstract Attribute createAttribute(String prefix, String namespaceURI, String localName, String value); |
|
251 |
||
252 |
/** |
|
253 |
* Create a new Attribute |
|
254 |
* @param localName the local name of the XML name of the attribute, localName cannot be null |
|
255 |
* @param value the attribute value to set, may not be null |
|
256 |
* @return the Attribute with specified values |
|
257 |
*/ |
|
258 |
public abstract Attribute createAttribute(String localName, String value); |
|
259 |
||
260 |
/** |
|
261 |
* Create a new Attribute |
|
262 |
* @param name the qualified name of the attribute, may not be null |
|
263 |
* @param value the attribute value to set, may not be null |
|
264 |
* @return the Attribute with specified values |
|
265 |
*/ |
|
266 |
public abstract Attribute createAttribute(QName name, String value); |
|
267 |
||
268 |
/** |
|
269 |
* Create a new default Namespace |
|
270 |
* @param namespaceURI the default namespace uri |
|
271 |
* @return the Namespace with the specified value |
|
272 |
*/ |
|
273 |
public abstract Namespace createNamespace(String namespaceURI); |
|
274 |
||
275 |
/** |
|
276 |
* Create a new Namespace |
|
277 |
* @param prefix the prefix of this namespace, may not be null |
|
278 |
* @param namespaceUri the attribute value is set to this value, may not be null |
|
279 |
* @return the Namespace with the specified values |
|
280 |
*/ |
|
281 |
public abstract Namespace createNamespace(String prefix, String namespaceUri); |
|
282 |
||
283 |
/** |
|
284 |
* Create a new StartElement. Namespaces can be added to this StartElement |
|
285 |
* by passing in an Iterator that walks over a set of Namespace interfaces. |
|
286 |
* Attributes can be added to this StartElement by passing an iterator |
|
287 |
* that walks over a set of Attribute interfaces. |
|
288 |
* |
|
289 |
* @param name the qualified name of the attribute, may not be null |
|
290 |
* @param attributes an optional unordered set of objects that |
|
291 |
* implement Attribute to add to the new StartElement, may be null |
|
292 |
* @param namespaces an optional unordered set of objects that |
|
293 |
* implement Namespace to add to the new StartElement, may be null |
|
294 |
* @return an instance of the requested StartElement |
|
295 |
*/ |
|
296 |
public abstract StartElement createStartElement(QName name, |
|
297 |
Iterator attributes, |
|
298 |
Iterator namespaces); |
|
299 |
||
300 |
/** |
|
301 |
* Create a new StartElement. This defaults the NamespaceContext to |
|
302 |
* an empty NamespaceContext. Querying this event for its namespaces or |
|
303 |
* attributes will result in an empty iterator being returned. |
|
304 |
* |
|
305 |
* @param namespaceUri the uri of the QName of the new StartElement |
|
306 |
* @param localName the local name of the QName of the new StartElement |
|
307 |
* @param prefix the prefix of the QName of the new StartElement |
|
308 |
* @return an instance of the requested StartElement |
|
309 |
*/ |
|
310 |
public abstract StartElement createStartElement(String prefix, |
|
311 |
String namespaceUri, |
|
312 |
String localName); |
|
313 |
/** |
|
314 |
* Create a new StartElement. Namespaces can be added to this StartElement |
|
315 |
* by passing in an Iterator that walks over a set of Namespace interfaces. |
|
316 |
* Attributes can be added to this StartElement by passing an iterator |
|
317 |
* that walks over a set of Attribute interfaces. |
|
318 |
* |
|
319 |
* @param namespaceUri the uri of the QName of the new StartElement |
|
320 |
* @param localName the local name of the QName of the new StartElement |
|
321 |
* @param prefix the prefix of the QName of the new StartElement |
|
322 |
* @param attributes an unordered set of objects that implement |
|
323 |
* Attribute to add to the new StartElement |
|
324 |
* @param namespaces an unordered set of objects that implement |
|
325 |
* Namespace to add to the new StartElement |
|
326 |
* @return an instance of the requested StartElement |
|
327 |
*/ |
|
328 |
public abstract StartElement createStartElement(String prefix, |
|
329 |
String namespaceUri, |
|
330 |
String localName, |
|
331 |
Iterator attributes, |
|
332 |
Iterator namespaces |
|
333 |
); |
|
334 |
/** |
|
335 |
* Create a new StartElement. Namespaces can be added to this StartElement |
|
336 |
* by passing in an Iterator that walks over a set of Namespace interfaces. |
|
337 |
* Attributes can be added to this StartElement by passing an iterator |
|
338 |
* that walks over a set of Attribute interfaces. |
|
339 |
* |
|
340 |
* @param namespaceUri the uri of the QName of the new StartElement |
|
341 |
* @param localName the local name of the QName of the new StartElement |
|
342 |
* @param prefix the prefix of the QName of the new StartElement |
|
343 |
* @param attributes an unordered set of objects that implement |
|
344 |
* Attribute to add to the new StartElement, may be null |
|
345 |
* @param namespaces an unordered set of objects that implement |
|
346 |
* Namespace to add to the new StartElement, may be null |
|
347 |
* @param context the namespace context of this element |
|
348 |
* @return an instance of the requested StartElement |
|
349 |
*/ |
|
350 |
public abstract StartElement createStartElement(String prefix, |
|
351 |
String namespaceUri, |
|
352 |
String localName, |
|
353 |
Iterator attributes, |
|
354 |
Iterator namespaces, |
|
355 |
NamespaceContext context |
|
356 |
); |
|
357 |
||
358 |
/** |
|
359 |
* Create a new EndElement |
|
360 |
* @param name the qualified name of the EndElement |
|
361 |
* @param namespaces an optional unordered set of objects that |
|
362 |
* implement Namespace that have gone out of scope, may be null |
|
363 |
* @return an instance of the requested EndElement |
|
364 |
*/ |
|
365 |
public abstract EndElement createEndElement(QName name, |
|
366 |
Iterator namespaces); |
|
367 |
||
368 |
/** |
|
369 |
* Create a new EndElement |
|
370 |
* @param namespaceUri the uri of the QName of the new StartElement |
|
371 |
* @param localName the local name of the QName of the new StartElement |
|
372 |
* @param prefix the prefix of the QName of the new StartElement |
|
373 |
* @return an instance of the requested EndElement |
|
374 |
*/ |
|
375 |
public abstract EndElement createEndElement(String prefix, |
|
376 |
String namespaceUri, |
|
377 |
String localName); |
|
378 |
/** |
|
379 |
* Create a new EndElement |
|
380 |
* @param namespaceUri the uri of the QName of the new StartElement |
|
381 |
* @param localName the local name of the QName of the new StartElement |
|
382 |
* @param prefix the prefix of the QName of the new StartElement |
|
383 |
* @param namespaces an unordered set of objects that implement |
|
384 |
* Namespace that have gone out of scope, may be null |
|
385 |
* @return an instance of the requested EndElement |
|
386 |
*/ |
|
387 |
public abstract EndElement createEndElement(String prefix, |
|
388 |
String namespaceUri, |
|
389 |
String localName, |
|
390 |
Iterator namespaces); |
|
391 |
||
392 |
/** |
|
393 |
* Create a Characters event, this method does not check if the content |
|
394 |
* is all whitespace. To create a space event use #createSpace(String) |
|
395 |
* @param content the string to create |
|
396 |
* @return a Characters event |
|
397 |
*/ |
|
398 |
public abstract Characters createCharacters(String content); |
|
399 |
||
400 |
/** |
|
401 |
* Create a Characters event with the CData flag set to true |
|
402 |
* @param content the string to create |
|
403 |
* @return a Characters event |
|
404 |
*/ |
|
405 |
public abstract Characters createCData(String content); |
|
406 |
||
407 |
/** |
|
408 |
* Create a Characters event with the isSpace flag set to true |
|
409 |
* @param content the content of the space to create |
|
410 |
* @return a Characters event |
|
411 |
*/ |
|
412 |
public abstract Characters createSpace(String content); |
|
413 |
/** |
|
414 |
* Create an ignorable space |
|
415 |
* @param content the space to create |
|
416 |
* @return a Characters event |
|
417 |
*/ |
|
418 |
public abstract Characters createIgnorableSpace(String content); |
|
419 |
||
420 |
/** |
|
421 |
* Creates a new instance of a StartDocument event |
|
422 |
* @return a StartDocument event |
|
423 |
*/ |
|
424 |
public abstract StartDocument createStartDocument(); |
|
425 |
||
426 |
/** |
|
427 |
* Creates a new instance of a StartDocument event |
|
428 |
* |
|
429 |
* @param encoding the encoding style |
|
430 |
* @param version the XML version |
|
431 |
* @param standalone the status of standalone may be set to "true" or "false" |
|
432 |
* @return a StartDocument event |
|
433 |
*/ |
|
434 |
public abstract StartDocument createStartDocument(String encoding, |
|
435 |
String version, |
|
436 |
boolean standalone); |
|
437 |
||
438 |
/** |
|
439 |
* Creates a new instance of a StartDocument event |
|
440 |
* |
|
441 |
* @param encoding the encoding style |
|
442 |
* @param version the XML version |
|
443 |
* @return a StartDocument event |
|
444 |
*/ |
|
445 |
public abstract StartDocument createStartDocument(String encoding, |
|
446 |
String version); |
|
447 |
||
448 |
/** |
|
449 |
* Creates a new instance of a StartDocument event |
|
450 |
* |
|
451 |
* @param encoding the encoding style |
|
452 |
* @return a StartDocument event |
|
453 |
*/ |
|
454 |
public abstract StartDocument createStartDocument(String encoding); |
|
455 |
||
456 |
/** |
|
457 |
* Creates a new instance of an EndDocument event |
|
458 |
* @return an EndDocument event |
|
459 |
*/ |
|
460 |
public abstract EndDocument createEndDocument(); |
|
461 |
||
462 |
/** Creates a new instance of a EntityReference event |
|
463 |
* |
|
464 |
* @param name The name of the reference |
|
465 |
* @param declaration the declaration for the event |
|
466 |
* @return an EntityReference event |
|
467 |
*/ |
|
468 |
public abstract EntityReference createEntityReference(String name, |
|
469 |
EntityDeclaration declaration); |
|
470 |
/** |
|
471 |
* Create a comment |
|
472 |
* @param text The text of the comment |
|
473 |
* a Comment event |
|
474 |
*/ |
|
475 |
public abstract Comment createComment(String text); |
|
476 |
||
477 |
/** |
|
478 |
* Create a processing instruction |
|
479 |
* @param target The target of the processing instruction |
|
480 |
* @param data The text of the processing instruction |
|
481 |
* @return a ProcessingInstruction event |
|
482 |
*/ |
|
483 |
public abstract ProcessingInstruction createProcessingInstruction(String target, |
|
484 |
String data); |
|
485 |
||
486 |
/** |
|
487 |
* Create a document type definition event |
|
488 |
* This string contains the entire document type declaration that matches |
|
489 |
* the doctypedecl in the XML 1.0 specification |
|
490 |
* @param dtd the text of the document type definition |
|
491 |
* @return a DTD event |
|
492 |
*/ |
|
493 |
public abstract DTD createDTD(String dtd); |
|
494 |
} |