1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363
font color='#880088'> package javax.xml.stream; import javax.xml.transform.Source; import javax.xml.stream.util.XMLEventAllocator; /** * Defines an abstract implementation of a factory for getting streams. * * The following table defines the standard properties of this specification. * Each property varies in the level of support required by each implementation. * The level of support required is described in the 'Required' column. * * <table border="2" rules="all" cellpadding="4"> * <thead> * <tr> * <th align="center" colspan="5"> * Configuration parameters * </th> * </tr> * </thead> * <tbody> * <tr> * <th>Property Name</th> * <th>Behavior</th> * <th>Return type</th> * <th>Default Value</th> * <th>Required</th> * </tr> * <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> * <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> * <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> * <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> *<tr><td>javax.xml.stream.isSupportingExternalEntities</td><td>Resolve external parsed entities</td><td>Boolean</td><td>Unspecified</td><td>Yes</td></tr> *<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> *<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> *<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> *<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> * </tbody> * </table> * * * @version 1.0 * @author Copyright (c) 2003 by BEA Systems. All Rights Reserved. * @see XMLOutputFactory * @see XMLEventReader * @see XMLStreamReader * @see EventFilter * @see XMLReporter * @see XMLResolver * @see javax.xml.stream.util.XMLEventAllocator * @since 1.6 */ public abstract class XMLInputFactory { /** * The property used to turn on/off namespace support, * this is to support XML 1.0 documents, * only the true setting must be supported */ public static final String IS_NAMESPACE_AWARE= "javax.xml.stream.isNamespaceAware"; /** * The property used to turn on/off implementation specific validation */ public static final String IS_VALIDATING= "javax.xml.stream.isValidating"; /** * The property that requires the parser to coalesce adjacent character data sections */ public static final String IS_COALESCING= "javax.xml.stream.isCoalescing"; /** * Requires the parser to replace internal * entity references with their replacement * text and report them as characters */ public static final String IS_REPLACING_ENTITY_REFERENCES= "javax.xml.stream.isReplacingEntityReferences"; /** * The property that requires the parser to resolve external parsed entities */ public static final String IS_SUPPORTING_EXTERNAL_ENTITIES= "javax.xml.stream.isSupportingExternalEntities"; /** * The property that requires the parser to support DTDs */ public static final String SUPPORT_DTD= "javax.xml.stream.supportDTD"; /** * The property used to * set/get the implementation of the XMLReporter interface */ public static final String REPORTER= "javax.xml.stream.reporter"; /** * The property used to set/get the implementation of the XMLResolver */ public static final String RESOLVER= "javax.xml.stream.resolver"; /** * The property used to set/get the implementation of the allocator */ public static final String ALLOCATOR= "javax.xml.stream.allocator"; protected XMLInputFactory(){} /** * Create a new instance of the factory. * This static method creates a new factory instance. * This method uses the following ordered lookup procedure to determine * the XMLInputFactory implementation class to load: * Use the javax.xml.stream.XMLInputFactory system property. * Use the properties file "lib/stax.properties" in the JRE directory. * This configuration file is in standard java.util.Properties format and contains * the fully qualified name of the implementation class with the key being the system property defined above. * Use the Services API (as detailed in the JAR specification), if available, to determine the classname. * The Services API will look for a classname in the file META-INF/services/javax.xml.stream.XMLInputFactory * in jars available to the runtime. * Platform default XMLInputFactory instance. * Once an application has obtained a reference to a XMLInputFactory * it can use the factory to configure and obtain stream instances. * * @throws FactoryConfigurationError if an instance of this factory cannot be loaded */ public static XMLInputFactory newInstance() throws FactoryConfigurationError { return (XMLInputFactory) FactoryFinder.find( "javax.xml.stream.XMLInputFactory", "com.sun.xml.internal.stream.XMLInputFactoryImpl"); } /** * Create a new instance of the factory * * @param factoryId Name of the factory to find, same as * a property name * @param classLoader classLoader to use * @return the factory implementation * @throws FactoryConfigurationError if an instance of this factory cannot be loaded */ public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError { try { //do not fallback if given classloader can't find the class, throw exception return (XMLInputFactory) FactoryFinder.newInstance(factoryId, classLoader, false); } catch (FactoryFinder.ConfigurationError e) { throw new FactoryConfigurationError(e.getException(), e.getMessage()); } } /** * Create a new XMLStreamReader from a reader * @param reader the XML data to read from * @throws XMLStreamException */ public abstract XMLStreamReader createXMLStreamReader(java.io.Reader reader) throws XMLStreamException; /** * Create a new XMLStreamReader from a JAXP source. This method is optional. * @param source the source to read from * @throws UnsupportedOperationException if this method is not * supported by this XMLInputFactory * @throws XMLStreamException */ public abstract XMLStreamReader createXMLStreamReader(Source source) throws XMLStreamException; /** * Create a new XMLStreamReader from a java.io.InputStream * @param stream the InputStream to read from * @throws XMLStreamException */ public abstract XMLStreamReader createXMLStreamReader(java.io.InputStream stream) throws XMLStreamException; /** * Create a new XMLStreamReader from a java.io.InputStream * @param stream the InputStream to read from * @param encoding the character encoding of the stream * @throws XMLStreamException */ public abstract XMLStreamReader createXMLStreamReader(java.io.InputStream stream, String encoding) throws XMLStreamException; /** * Create a new XMLStreamReader from a java.io.InputStream * @param systemId the system ID of the stream * @param stream the InputStream to read from */ public abstract XMLStreamReader createXMLStreamReader(String systemId, java.io.InputStream stream) throws XMLStreamException; /** * Create a new XMLStreamReader from a java.io.InputStream * @param systemId the system ID of the stream * @param reader the InputStream to read from */ public abstract XMLStreamReader createXMLStreamReader(String systemId, java.io.Reader reader) throws XMLStreamException; /** * Create a new XMLEventReader from a reader * @param reader the XML data to read from * @throws XMLStreamException */ public abstract XMLEventReader createXMLEventReader(java.io.Reader reader) throws XMLStreamException; /** * Create a new XMLEventReader from a reader * @param systemId the system ID of the input * @param reader the XML data to read from * @throws XMLStreamException */ public abstract XMLEventReader createXMLEventReader(String systemId, java.io.Reader reader) throws XMLStreamException; /** * Create a new XMLEventReader from an XMLStreamReader. After being used * to construct the XMLEventReader instance returned from this method * the XMLStreamReader must not be used. * @param reader the XMLStreamReader to read from (may not be modified) * @return a new XMLEventReader * @throws XMLStreamException */ public abstract XMLEventReader createXMLEventReader(XMLStreamReader reader) throws XMLStreamException; /** * Create a new XMLEventReader from a JAXP source. * Support of this method is optional. * @param source the source to read from * @throws UnsupportedOperationException if this method is not * supported by this XMLInputFactory */ public abstract XMLEventReader createXMLEventReader(Source source) throws XMLStreamException; /** * Create a new XMLEventReader from a java.io.InputStream * @param stream the InputStream to read from * @throws XMLStreamException */ public abstract XMLEventReader createXMLEventReader(java.io.InputStream stream) throws XMLStreamException; /** * Create a new XMLEventReader from a java.io.InputStream * @param stream the InputStream to read from * @param encoding the character encoding of the stream * @throws XMLStreamException */ public abstract XMLEventReader createXMLEventReader(java.io.InputStream stream, String encoding) throws XMLStreamException; /** * Create a new XMLEventReader from a java.io.InputStream * @param systemId the system ID of the stream * @param stream the InputStream to read from * @throws XMLStreamException */ public abstract XMLEventReader createXMLEventReader(String systemId, java.io.InputStream stream) throws XMLStreamException; /** * Create a filtered reader that wraps the filter around the reader * @param reader the reader to filter * @param filter the filter to apply to the reader * @throws XMLStreamException */ public abstract XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException; /** * Create a filtered event reader that wraps the filter around the event reader * @param reader the event reader to wrap * @param filter the filter to apply to the event reader * @throws XMLStreamException */ public abstract XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException; /** * The resolver that will be set on any XMLStreamReader or XMLEventReader created * by this factory instance. */ public abstract XMLResolver getXMLResolver(); /** * The resolver that will be set on any XMLStreamReader or XMLEventReader created * by this factory instance. * @param resolver the resolver to use to resolve references */ public abstract void setXMLResolver(XMLResolver resolver); /** * The reporter that will be set on any XMLStreamReader or XMLEventReader created * by this factory instance. */ public abstract XMLReporter getXMLReporter(); /** * The reporter that will be set on any XMLStreamReader or XMLEventReader created * by this factory instance. * @param reporter the resolver to use to report non fatal errors */ public abstract void setXMLReporter(XMLReporter reporter); /** * Allows the user to set specific feature/property on the underlying implementation. The underlying implementation * is not required to support every setting of every property in the specification and may use IllegalArgumentException * to signal that an unsupported property may not be set with the specified value. * @param name The name of the property (may not be null) * @param value The value of the property * @throws java.lang.IllegalArgumentException if the property is not supported */ public abstract void setProperty(java.lang.String name, Object value) throws java.lang.IllegalArgumentException; /** * Get the value of a feature/property from the underlying implementation * @param name The name of the property (may not be null) * @return The value of the property * @throws IllegalArgumentException if the property is not supported */ public abstract Object getProperty(java.lang.String name) throws java.lang.IllegalArgumentException; /** * Query the set of properties that this factory supports. * * @param name The name of the property (may not be null) * @return true if the property is supported and false otherwise */ public abstract boolean isPropertySupported(String name); /** * Set a user defined event allocator for events * @param allocator the user defined allocator */ public abstract void setEventAllocator(XMLEventAllocator allocator); /** * Gets the allocator used by streams created with this factory */ public abstract XMLEventAllocator getEventAllocator(); }