/* * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms. * * * * * * * * * * * * * * * * * * * * */ /* * Copyright (c) 2009, 2013, by Oracle Corporation. All Rights Reserved. */ package javax.xml.stream; import javax.xml.stream.util.XMLEventAllocator; import javax.xml.transform.Source; /** * 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. * *
* Configuration parameters * | *||||
---|---|---|---|---|
Property Name | *Behavior | *Return type | *Default Value | *Required | *
javax.xml.stream.isValidating | Turns on/off implementation specific DTD validation | Boolean | False | No |
javax.xml.stream.isNamespaceAware | Turns on/off namespace processing for XML 1.0 support | Boolean | True | True (required) / False (optional) |
javax.xml.stream.isCoalescing | Requires the processor to coalesce adjacent character data | Boolean | False | Yes |
javax.xml.stream.isReplacingEntityReferences | replace internal entity references with their replacement text and report them as characters | Boolean | True | Yes |
javax.xml.stream.isSupportingExternalEntities | Resolve external parsed entities | Boolean | Unspecified | Yes |
javax.xml.stream.supportDTD | Use this property to request processors that do not support DTDs | Boolean | True | Yes |
javax.xml.stream.reporter | sets/gets the impl of the XMLReporter | javax.xml.stream.XMLReporter | Null | Yes |
javax.xml.stream.resolver | sets/gets the impl of the XMLResolver interface | javax.xml.stream.XMLResolver | Null | Yes |
javax.xml.stream.allocator | sets/gets the impl of the XMLEventAllocator interface | javax.xml.stream.util.XMLEventAllocator | Null | Yes |
* This static method creates a new factory instance. * This method uses the following ordered lookup procedure to determine * the XMLInputFactory implementation class to load: *
** Once an application has obtained a reference to a XMLInputFactory it * can use the factory to configure and obtain stream instances. *
** Note that this is a new method that replaces the deprecated newInstance() method. * No changes in behavior are defined by this replacement method relative to * the deprecated method. *
* @throws FactoryConfigurationError in case of {@linkplain * java.util.ServiceConfigurationError service configuration error} or if * the implementation is not available or cannot be instantiated. */ public static XMLInputFactory newFactory() throws FactoryConfigurationError { return FactoryFinder.find(XMLInputFactory.class, DEFAULIMPL); } /** * 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 * * @deprecated This method has been deprecated to maintain API consistency. * All newInstance methods have been replaced with corresponding * newFactory methods. The replacement {@link * #newFactory(java.lang.String, java.lang.ClassLoader)} method * defines no changes in behavior. */ public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError { //do not fallback if given classloader can't find the class, throw exception return FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null); } /** * Create a new instance of the factory. * If the classLoader argument is null, then the ContextClassLoader is used. ** This method uses the following ordered lookup procedure to determine * the XMLInputFactory implementation class to load: *
** Note that this is a new method that replaces the deprecated * {@link #newInstance(java.lang.String, java.lang.ClassLoader) * newInstance(String factoryId, ClassLoader classLoader)} method. * No changes in behavior are defined by this replacement method relative * to the deprecated method. *
* * @apiNote The parameter factoryId defined here is inconsistent with that * of other JAXP factories where the first parameter is fully qualified * factory class name that provides implementation 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 in case of {@linkplain * java.util.ServiceConfigurationError service configuration error} or if * the implementation is not available or cannot be instantiated. * @throws FactoryConfigurationError if an instance of this factory cannot be loaded */ public static XMLInputFactory newFactory(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError { //do not fallback if given classloader can't find the class, throw exception return FactoryFinder.find(XMLInputFactory.class, factoryId, classLoader, null); } /** * 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. ** All implementations that implement JAXP 1.5 or newer are required to * support the {@link javax.xml.XMLConstants#ACCESS_EXTERNAL_DTD} property. *
** Access to external DTDs, external Entity References is restricted to the * protocols specified by the property. If access is denied during parsing * due to the restriction of this property, {@link javax.xml.stream.XMLStreamException} * will be thrown by the {@link javax.xml.stream.XMLStreamReader#next()} or * {@link javax.xml.stream.XMLEventReader#nextEvent()} method. *
*