- java.lang.Object
-
- javax.xml.stream.XMLInputFactory
-
public abstract class XMLInputFactory extends Object
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 - Since:
- 1.6
- See Also:
XMLOutputFactory
,XMLEventReader
,XMLStreamReader
,EventFilter
,XMLReporter
,XMLResolver
,XMLEventAllocator
-
-
Field Summary
Fields Modifier and Type Field and Description static String
ALLOCATOR
The property used to set/get the implementation of the allocatorstatic String
IS_COALESCING
The property that requires the parser to coalesce adjacent character data sectionsstatic String
IS_NAMESPACE_AWARE
The property used to turn on/off namespace support, this is to support XML 1.0 documents, only the true setting must be supportedstatic String
IS_REPLACING_ENTITY_REFERENCES
Requires the parser to replace internal entity references with their replacement text and report them as charactersstatic String
IS_SUPPORTING_EXTERNAL_ENTITIES
The property that requires the parser to resolve external parsed entitiesstatic String
IS_VALIDATING
The property used to turn on/off implementation specific validationstatic String
REPORTER
The property used to set/get the implementation of the XMLReporter interfacestatic String
RESOLVER
The property used to set/get the implementation of the XMLResolverstatic String
SUPPORT_DTD
The property that requires the parser to support DTDs
-
Constructor Summary
Constructors Modifier Constructor and Description protected
XMLInputFactory()
-
Method Summary
Methods Modifier and Type Method and Description abstract XMLEventReader
createFilteredReader(XMLEventReader reader, EventFilter filter)
Create a filtered event reader that wraps the filter around the event readerabstract XMLStreamReader
createFilteredReader(XMLStreamReader reader, StreamFilter filter)
Create a filtered reader that wraps the filter around the readerabstract XMLEventReader
createXMLEventReader(InputStream stream)
Create a new XMLEventReader from a java.io.InputStreamabstract XMLEventReader
createXMLEventReader(InputStream stream, String encoding)
Create a new XMLEventReader from a java.io.InputStreamabstract XMLEventReader
createXMLEventReader(Reader reader)
Create a new XMLEventReader from a readerabstract XMLEventReader
createXMLEventReader(Source source)
Create a new XMLEventReader from a JAXP source.abstract XMLEventReader
createXMLEventReader(String systemId, InputStream stream)
Create a new XMLEventReader from a java.io.InputStreamabstract XMLEventReader
createXMLEventReader(String systemId, Reader reader)
Create a new XMLEventReader from a readerabstract XMLEventReader
createXMLEventReader(XMLStreamReader reader)
Create a new XMLEventReader from an XMLStreamReader.abstract XMLStreamReader
createXMLStreamReader(InputStream stream)
Create a new XMLStreamReader from a java.io.InputStreamabstract XMLStreamReader
createXMLStreamReader(InputStream stream, String encoding)
Create a new XMLStreamReader from a java.io.InputStreamabstract XMLStreamReader
createXMLStreamReader(Reader reader)
Create a new XMLStreamReader from a readerabstract XMLStreamReader
createXMLStreamReader(Source source)
Create a new XMLStreamReader from a JAXP source.abstract XMLStreamReader
createXMLStreamReader(String systemId, InputStream stream)
Create a new XMLStreamReader from a java.io.InputStreamabstract XMLStreamReader
createXMLStreamReader(String systemId, Reader reader)
Create a new XMLStreamReader from a java.io.InputStreamabstract XMLEventAllocator
getEventAllocator()
Gets the allocator used by streams created with this factoryabstract Object
getProperty(String name)
Get the value of a feature/property from the underlying implementationabstract XMLReporter
getXMLReporter()
The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.abstract XMLResolver
getXMLResolver()
The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.abstract boolean
isPropertySupported(String name)
Query the set of properties that this factory supports.static XMLInputFactory
newFactory()
Create a new instance of the factory.static XMLInputFactory
newFactory(String factoryId, ClassLoader classLoader)
Create a new instance of the factory.static XMLInputFactory
newInstance()
Create a new instance of the factory.static XMLInputFactory
newInstance(String factoryId, ClassLoader classLoader)
Deprecated.This method has been deprecated to maintain API consistency. All newInstance methods have been replaced with corresponding newFactory methods. The replacementnewFactory(java.lang.String, java.lang.ClassLoader)
method defines no changes in behavior.abstract void
setEventAllocator(XMLEventAllocator allocator)
Set a user defined event allocator for eventsabstract void
setProperty(String name, Object value)
Allows the user to set specific feature/property on the underlying implementation.abstract void
setXMLReporter(XMLReporter reporter)
The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.abstract void
setXMLResolver(XMLResolver resolver)
The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.
-
-
-
Field Detail
-
IS_NAMESPACE_AWARE
public static final String IS_NAMESPACE_AWARE
The property used to turn on/off namespace support, this is to support XML 1.0 documents, only the true setting must be supported- See Also:
- Constant Field Values
-
IS_VALIDATING
public static final String IS_VALIDATING
The property used to turn on/off implementation specific validation- See Also:
- Constant Field Values
-
IS_COALESCING
public static final String IS_COALESCING
The property that requires the parser to coalesce adjacent character data sections- See Also:
- Constant Field Values
-
IS_REPLACING_ENTITY_REFERENCES
public static final String IS_REPLACING_ENTITY_REFERENCES
Requires the parser to replace internal entity references with their replacement text and report them as characters- See Also:
- Constant Field Values
-
IS_SUPPORTING_EXTERNAL_ENTITIES
public static final String IS_SUPPORTING_EXTERNAL_ENTITIES
The property that requires the parser to resolve external parsed entities- See Also:
- Constant Field Values
-
SUPPORT_DTD
public static final String SUPPORT_DTD
The property that requires the parser to support DTDs- See Also:
- Constant Field Values
-
REPORTER
public static final String REPORTER
The property used to set/get the implementation of the XMLReporter interface- See Also:
- Constant Field Values
-
RESOLVER
public static final String RESOLVER
The property used to set/get the implementation of the XMLResolver- See Also:
- Constant Field Values
-
ALLOCATOR
public static final String ALLOCATOR
The property used to set/get the implementation of the allocator- See Also:
- Constant Field Values
-
-
Method Detail
-
newInstance
public static XMLInputFactory newInstance() throws FactoryConfigurationError
Create a new instance of the factory.- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
newFactory
public static XMLInputFactory newFactory() throws FactoryConfigurationError
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. 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
- if an instance of this factory cannot be loaded
-
newInstance
public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError
Deprecated. This method has been deprecated to maintain API consistency. All newInstance methods have been replaced with corresponding newFactory methods. The replacementnewFactory(java.lang.String, java.lang.ClassLoader)
method defines no changes in behavior.Create a new instance of the factory- Parameters:
factoryId
- Name of the factory to find, same as a property nameclassLoader
- classLoader to use- Returns:
- the factory implementation
- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
newFactory
public static XMLInputFactory newFactory(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError
Create a new instance of the factory. If the classLoader argument is null, then the ContextClassLoader is used. Note that this is a new method that replaces the deprecated newInstance(String factoryId, ClassLoader classLoader) method. No changes in behavior are defined by this replacement method relative to the deprecated method.- Parameters:
factoryId
- Name of the factory to find, same as a property nameclassLoader
- classLoader to use- Returns:
- the factory implementation
- Throws:
FactoryConfigurationError
- if an instance of this factory cannot be loaded
-
createXMLStreamReader
public abstract XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException
Create a new XMLStreamReader from a reader- Parameters:
reader
- the XML data to read from- Throws:
XMLStreamException
-
createXMLStreamReader
public abstract XMLStreamReader createXMLStreamReader(Source source) throws XMLStreamException
Create a new XMLStreamReader from a JAXP source. This method is optional.- Parameters:
source
- the source to read from- Throws:
UnsupportedOperationException
- if this method is not supported by this XMLInputFactoryXMLStreamException
-
createXMLStreamReader
public abstract XMLStreamReader createXMLStreamReader(InputStream stream) throws XMLStreamException
Create a new XMLStreamReader from a java.io.InputStream- Parameters:
stream
- the InputStream to read from- Throws:
XMLStreamException
-
createXMLStreamReader
public abstract XMLStreamReader createXMLStreamReader(InputStream stream, String encoding) throws XMLStreamException
Create a new XMLStreamReader from a java.io.InputStream- Parameters:
stream
- the InputStream to read fromencoding
- the character encoding of the stream- Throws:
XMLStreamException
-
createXMLStreamReader
public abstract XMLStreamReader createXMLStreamReader(String systemId, InputStream stream) throws XMLStreamException
Create a new XMLStreamReader from a java.io.InputStream- Parameters:
systemId
- the system ID of the streamstream
- the InputStream to read from- Throws:
XMLStreamException
-
createXMLStreamReader
public abstract XMLStreamReader createXMLStreamReader(String systemId, Reader reader) throws XMLStreamException
Create a new XMLStreamReader from a java.io.InputStream- Parameters:
systemId
- the system ID of the streamreader
- the InputStream to read from- Throws:
XMLStreamException
-
createXMLEventReader
public abstract XMLEventReader createXMLEventReader(Reader reader) throws XMLStreamException
Create a new XMLEventReader from a reader- Parameters:
reader
- the XML data to read from- Throws:
XMLStreamException
-
createXMLEventReader
public abstract XMLEventReader createXMLEventReader(String systemId, Reader reader) throws XMLStreamException
Create a new XMLEventReader from a reader- Parameters:
systemId
- the system ID of the inputreader
- the XML data to read from- Throws:
XMLStreamException
-
createXMLEventReader
public abstract XMLEventReader createXMLEventReader(XMLStreamReader 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.- Parameters:
reader
- the XMLStreamReader to read from (may not be modified)- Returns:
- a new XMLEventReader
- Throws:
XMLStreamException
-
createXMLEventReader
public abstract XMLEventReader createXMLEventReader(Source source) throws XMLStreamException
Create a new XMLEventReader from a JAXP source. Support of this method is optional.- Parameters:
source
- the source to read from- Throws:
UnsupportedOperationException
- if this method is not supported by this XMLInputFactoryXMLStreamException
-
createXMLEventReader
public abstract XMLEventReader createXMLEventReader(InputStream stream) throws XMLStreamException
Create a new XMLEventReader from a java.io.InputStream- Parameters:
stream
- the InputStream to read from- Throws:
XMLStreamException
-
createXMLEventReader
public abstract XMLEventReader createXMLEventReader(InputStream stream, String encoding) throws XMLStreamException
Create a new XMLEventReader from a java.io.InputStream- Parameters:
stream
- the InputStream to read fromencoding
- the character encoding of the stream- Throws:
XMLStreamException
-
createXMLEventReader
public abstract XMLEventReader createXMLEventReader(String systemId, InputStream stream) throws XMLStreamException
Create a new XMLEventReader from a java.io.InputStream- Parameters:
systemId
- the system ID of the streamstream
- the InputStream to read from- Throws:
XMLStreamException
-
createFilteredReader
public abstract XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException
Create a filtered reader that wraps the filter around the reader- Parameters:
reader
- the reader to filterfilter
- the filter to apply to the reader- Throws:
XMLStreamException
-
createFilteredReader
public abstract XMLEventReader createFilteredReader(XMLEventReader reader, EventFilter filter) throws XMLStreamException
Create a filtered event reader that wraps the filter around the event reader- Parameters:
reader
- the event reader to wrapfilter
- the filter to apply to the event reader- Throws:
XMLStreamException
-
getXMLResolver
public abstract XMLResolver getXMLResolver()
The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.
-
setXMLResolver
public abstract void setXMLResolver(XMLResolver resolver)
The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.- Parameters:
resolver
- the resolver to use to resolve references
-
getXMLReporter
public abstract XMLReporter getXMLReporter()
The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.
-
setXMLReporter
public abstract void setXMLReporter(XMLReporter reporter)
The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.- Parameters:
reporter
- the resolver to use to report non fatal errors
-
setProperty
public abstract void setProperty(String name, Object value) throws IllegalArgumentException
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
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,
XMLStreamException
will be thrown by theXMLStreamReader.next()
orXMLEventReader.nextEvent()
method.
- Parameters:
name
- The name of the property (may not be null)value
- The value of the property- Throws:
IllegalArgumentException
- if the property is not supported
-
-
getProperty
public abstract Object getProperty(String name) throws IllegalArgumentException
Get the value of a feature/property from the underlying implementation- Parameters:
name
- The name of the property (may not be null)- Returns:
- The value of the property
- Throws:
IllegalArgumentException
- if the property is not supported
-
isPropertySupported
public abstract boolean isPropertySupported(String name)
Query the set of properties that this factory supports.- Parameters:
name
- The name of the property (may not be null)- Returns:
- true if the property is supported and false otherwise
-
setEventAllocator
public abstract void setEventAllocator(XMLEventAllocator allocator)
Set a user defined event allocator for events- Parameters:
allocator
- the user defined allocator
-
getEventAllocator
public abstract XMLEventAllocator getEventAllocator()
Gets the allocator used by streams created with this factory
-
-
Nederlandse vertaling
U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.
Bij voorbaat dank.
Document heeft de 11/06/2005 gemaakt, de laatste keer de 04/03/2020 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/java-api-rf-javax/xml/stream/xmlinputfactory.html
De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.
Referenties
Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.