APIdia Launch Partner
Top Description Fields Constructors Methods
javax.xml.stream

public abstract Class XMLInputFactory

extends Object
Class Inheritance
Known Direct Subclasses
com.sun.xml.internal.stream.XMLInputFactoryImpl
Imports
com.sun.xml.internal.stream.XMLInputFactoryImpl, javax.xml.stream.util.XMLEventAllocator, 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.isValidatingTurns on/off implementation specific DTD validationBooleanFalseNo
javax.xml.stream.isNamespaceAwareTurns on/off namespace processing for XML 1.0 supportBooleanTrueTrue (required) / False (optional)
javax.xml.stream.isCoalescingRequires the processor to coalesce adjacent character dataBooleanFalseYes
javax.xml.stream.isReplacingEntityReferencesreplace internal entity references with their replacement text and report them as charactersBooleanTrueYes
javax.xml.stream.isSupportingExternalEntitiesResolve external parsed entitiesBooleanUnspecifiedYes
javax.xml.stream.supportDTDUse this property to request processors that do not support DTDsBooleanTrueYes
javax.xml.stream.reportersets/gets the impl of the XMLReporter javax.xml.stream.XMLReporterNullYes
javax.xml.stream.resolversets/gets the impl of the XMLResolver interfacejavax.xml.stream.XMLResolverNullYes
javax.xml.stream.allocatorsets/gets the impl of the XMLEventAllocator interfacejavax.xml.stream.util.XMLEventAllocatorNullYes
Author
Copyright (c) 2009, 2015 by Oracle Corporation. All Rights Reserved.
Since
1.6
Version
1.2
See Also
XMLOutputFactory, XMLEventReader, XMLStreamReader, EventFilter, XMLReporter, XMLResolver, javax.xml.stream.util.XMLEventAllocator

Field Summary

Modifier and TypeField and Description
public static final String
ALLOCATOR

The property used to set/get the implementation of the allocator

pack-priv static final String
public static final String
IS_COALESCING

The property that requires the parser to coalesce adjacent character data sections

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

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

public static final String
IS_SUPPORTING_EXTERNAL_ENTITIES

The property that requires the parser to resolve external parsed entities

public static final String
IS_VALIDATING

The property used to turn on/off implementation specific validation

public static final String
REPORTER

The property used to set/get the implementation of the XMLReporter interface

public static final String
RESOLVER

The property used to set/get the implementation of the XMLResolver

public static final String
SUPPORT_DTD

The property that requires the parser to support DTDs

Constructor Summary

AccessConstructor and Description
protected
XMLInputFactory()

Protected constructor to prevent instantiation.

Method Summary

Modifier and TypeMethod and Description
public abstract XMLStreamReader

Returns:

an instance of the XMLEventReader
createFilteredReader
(XMLStreamReader
the reader to filter
reader
,
StreamFilter
the filter to apply to the reader
filter
)

Create a filtered reader that wraps the filter around the reader

public abstract XMLEventReader

Returns:

an instance of the XMLEventReader
createFilteredReader
(XMLEventReader
the event reader to wrap
reader
,
EventFilter
the filter to apply to the event reader
filter
)

Create a filtered event reader that wraps the filter around the event reader

public abstract XMLEventReader

Returns:

an instance of the XMLEventReader
createXMLEventReader
(Reader
the XML data to read from
reader
)

Create a new XMLEventReader from a reader.

public abstract XMLEventReader

Returns:

an instance of the XMLEventReader
createXMLEventReader
(String
the system ID of the input
systemId
,
Reader
the XML data to read from
reader
)

Create a new XMLEventReader from a reader.

public abstract XMLEventReader

Returns:

a new XMLEventReader
createXMLEventReader
(XMLStreamReader
the XMLStreamReader to read from (may not be modified)
reader
)

Create a new XMLEventReader from an XMLStreamReader.

public abstract XMLEventReader

Returns:

an instance of the XMLEventReader
createXMLEventReader
(Source
the source to read from
source
)

Create a new XMLEventReader from a JAXP source.

public abstract XMLEventReader

Returns:

an instance of the XMLEventReader
createXMLEventReader
(InputStream
the InputStream to read from
stream
)

Create a new XMLEventReader from a java.io.InputStream

public abstract XMLEventReader

Returns:

an instance of the XMLEventReader
createXMLEventReader
(InputStream
the InputStream to read from
stream
,
String
the character encoding of the stream
encoding
)

Create a new XMLEventReader from a java.io.InputStream

public abstract XMLEventReader

Returns:

an instance of the XMLEventReader
createXMLEventReader
(String
the system ID of the stream
systemId
,
InputStream
the InputStream to read from
stream
)

Create a new XMLEventReader from a java.io.InputStream

public abstract XMLStreamReader

Returns:

an instance of the XMLStreamReader
createXMLStreamReader
(Reader
the XML data to read from
reader
)

Create a new XMLStreamReader from a reader.

public abstract XMLStreamReader

Returns:

an instance of the XMLStreamReader
createXMLStreamReader
(Source
the source to read from
source
)

Create a new XMLStreamReader from a JAXP source.

public abstract XMLStreamReader

Returns:

an instance of the XMLStreamReader
createXMLStreamReader
(InputStream
the InputStream to read from
stream
)

Create a new XMLStreamReader from a java.io.InputStream.

public abstract XMLStreamReader

Returns:

an instance of the XMLStreamReader
createXMLStreamReader
(InputStream
the InputStream to read from
stream
,
String
the character encoding of the stream
encoding
)

Create a new XMLStreamReader from a java.io.InputStream.

public abstract XMLStreamReader

Returns:

an instance of the XMLStreamReader
createXMLStreamReader
(String
the system ID of the stream
systemId
,
InputStream
the InputStream to read from
stream
)

Create a new XMLStreamReader from a java.io.InputStream.

public abstract XMLStreamReader

Returns:

an instance of the XMLStreamReader
createXMLStreamReader
(String
the system ID of the stream
systemId
,
Reader
the InputStream to read from
reader
)

Create a new XMLStreamReader from a java.io.InputStream.

public abstract XMLEventAllocator

Returns:

an instance of the XMLEventAllocator
getEventAllocator
()

Gets the allocator used by streams created with this factory

public abstract Object

Returns:

The value of the property
getProperty
(String
The name of the property (may not be null)
name
)

Get the value of a feature/property from the underlying implementation

public abstract XMLReporter

Returns:

an instance of the XMLReporter
getXMLReporter
()

The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

public abstract XMLResolver

Returns:

an instance of the XMLResolver
getXMLResolver
()

The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

public abstract boolean

Returns:

true if the property is supported and false otherwise
isPropertySupported
(String
The name of the property (may not be null)
name
)

Query the set of properties that this factory supports.

public static XMLInputFactory

Returns:

A new instance of the XMLInputFactory builtin system-default implementation.
newDefaultFactory
()

Creates a new instance of the XMLInputFactory builtin system-default implementation.

public static XMLInputFactory

Returns:

an instance of the XMLInputFactory
newFactory
()

Creates a new instance of the factory.

public static XMLInputFactory

Returns:

the factory implementation
newFactory
(String
Name of the factory to find, same as a property name
factoryId
,
ClassLoader
classLoader to use
classLoader
)

Create a new instance of the factory.

public static XMLInputFactory

Returns:

an instance of the XMLInputFactory
newInstance
()

Creates a new instance of the factory in exactly the same manner as the newFactory() method.

public static XMLInputFactory

Returns:

the factory implementation
newInstance
(String
Name of the factory to find, same as a property name
factoryId
,
ClassLoader
classLoader to use
classLoader
)
Deprecated since 1.7. This method has been deprecated to maintain API consistency.

Create a new instance of the factory.

public abstract void
setEventAllocator(XMLEventAllocator
the user defined allocator
allocator
)

Set a user defined event allocator for events

public abstract void
setProperty(String
The name of the property (may not be null)
name
,
Object
The value of the property
value
)

Allows the user to set specific feature/property on the underlying implementation.

public abstract void
setXMLReporter(XMLReporter
the resolver to use to report non fatal errors
reporter
)

The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

public abstract void
setXMLResolver(XMLResolver
the resolver to use to resolve references
resolver
)

The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

ALLOCATORback to summary
public static final String ALLOCATOR

The property used to set/get the implementation of the allocator

DEFAULIMPLback to summary
pack-priv static final String DEFAULIMPL
IS_COALESCINGback to summary
public static final String IS_COALESCING

The property that requires the parser to coalesce adjacent character data sections

IS_NAMESPACE_AWAREback to summary
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

IS_REPLACING_ENTITY_REFERENCESback to summary
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

IS_SUPPORTING_EXTERNAL_ENTITIESback to summary
public static final String IS_SUPPORTING_EXTERNAL_ENTITIES

The property that requires the parser to resolve external parsed entities

IS_VALIDATINGback to summary
public static final String IS_VALIDATING

The property used to turn on/off implementation specific validation

REPORTERback to summary
public static final String REPORTER

The property used to set/get the implementation of the XMLReporter interface

RESOLVERback to summary
public static final String RESOLVER

The property used to set/get the implementation of the XMLResolver

SUPPORT_DTDback to summary
public static final String SUPPORT_DTD

The property that requires the parser to support DTDs

Constructor Detail

XMLInputFactoryback to summary
protected XMLInputFactory()

Protected constructor to prevent instantiation. Use newFactory() instead.

Method Detail

createFilteredReaderback to summary
public abstract XMLStreamReader createFilteredReader(XMLStreamReader reader, StreamFilter filter) throws XMLStreamException

Create a filtered reader that wraps the filter around the reader

Parameters
reader:XMLStreamReader

the reader to filter

filter:StreamFilter

the filter to apply to the reader

Returns:XMLStreamReader

an instance of the XMLEventReader

Exceptions
XMLStreamException:
if an error occurs
createFilteredReaderback to summary
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:XMLEventReader

the event reader to wrap

filter:EventFilter

the filter to apply to the event reader

Returns:XMLEventReader

an instance of the XMLEventReader

Exceptions
XMLStreamException:
if an error occurs
createXMLEventReaderback to summary
public abstract XMLEventReader createXMLEventReader(Reader reader) throws XMLStreamException

Create a new XMLEventReader from a reader.

Parameters
reader:Reader

the XML data to read from

Returns:XMLEventReader

an instance of the XMLEventReader

Exceptions
XMLStreamException:
if an error occurs
createXMLEventReaderback to summary
public abstract XMLEventReader createXMLEventReader(String systemId, Reader reader) throws XMLStreamException

Create a new XMLEventReader from a reader.

Parameters
systemId:String

the system ID of the input

reader:Reader

the XML data to read from

Returns:XMLEventReader

an instance of the XMLEventReader

Exceptions
XMLStreamException:
if an error occurs
createXMLEventReaderback to summary
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:XMLStreamReader

the XMLStreamReader to read from (may not be modified)

Returns:XMLEventReader

a new XMLEventReader

Exceptions
XMLStreamException:
if an error occurs
createXMLEventReaderback to summary
public abstract XMLEventReader createXMLEventReader(Source source) throws XMLStreamException

Create a new XMLEventReader from a JAXP source. Support of this method is optional.

Parameters
source:Source

the source to read from

Returns:XMLEventReader

an instance of the XMLEventReader

Exceptions
XMLStreamException:
if an error occurs
UnsupportedOperationException:
if this method is not supported by this XMLInputFactory
createXMLEventReaderback to summary
public abstract XMLEventReader createXMLEventReader(InputStream stream) throws XMLStreamException

Create a new XMLEventReader from a java.io.InputStream

Parameters
stream:InputStream

the InputStream to read from

Returns:XMLEventReader

an instance of the XMLEventReader

Exceptions
XMLStreamException:
if an error occurs
createXMLEventReaderback to summary
public abstract XMLEventReader createXMLEventReader(InputStream stream, String encoding) throws XMLStreamException

Create a new XMLEventReader from a java.io.InputStream

Parameters
stream:InputStream

the InputStream to read from

encoding:String

the character encoding of the stream

Returns:XMLEventReader

an instance of the XMLEventReader

Exceptions
XMLStreamException:
if an error occurs
createXMLEventReaderback to summary
public abstract XMLEventReader createXMLEventReader(String systemId, InputStream stream) throws XMLStreamException

Create a new XMLEventReader from a java.io.InputStream

Parameters
systemId:String

the system ID of the stream

stream:InputStream

the InputStream to read from

Returns:XMLEventReader

an instance of the XMLEventReader

Exceptions
XMLStreamException:
if an error occurs
createXMLStreamReaderback to summary
public abstract XMLStreamReader createXMLStreamReader(Reader reader) throws XMLStreamException

Create a new XMLStreamReader from a reader.

Parameters
reader:Reader

the XML data to read from

Returns:XMLStreamReader

an instance of the XMLStreamReader

Exceptions
XMLStreamException:
if an error occurs
createXMLStreamReaderback to summary
public abstract XMLStreamReader createXMLStreamReader(Source source) throws XMLStreamException

Create a new XMLStreamReader from a JAXP source. This method is optional.

Parameters
source:Source

the source to read from

Returns:XMLStreamReader

an instance of the XMLStreamReader

Exceptions
XMLStreamException:
if an error occurs
UnsupportedOperationException:
if this method is not supported by this XMLInputFactory
createXMLStreamReaderback to summary
public abstract XMLStreamReader createXMLStreamReader(InputStream stream) throws XMLStreamException

Create a new XMLStreamReader from a java.io.InputStream.

Parameters
stream:InputStream

the InputStream to read from

Returns:XMLStreamReader

an instance of the XMLStreamReader

Exceptions
XMLStreamException:
if an error occurs
createXMLStreamReaderback to summary
public abstract XMLStreamReader createXMLStreamReader(InputStream stream, String encoding) throws XMLStreamException

Create a new XMLStreamReader from a java.io.InputStream.

Parameters
stream:InputStream

the InputStream to read from

encoding:String

the character encoding of the stream

Returns:XMLStreamReader

an instance of the XMLStreamReader

Exceptions
XMLStreamException:
if an error occurs
createXMLStreamReaderback to summary
public abstract XMLStreamReader createXMLStreamReader(String systemId, InputStream stream) throws XMLStreamException

Create a new XMLStreamReader from a java.io.InputStream.

Parameters
systemId:String

the system ID of the stream

stream:InputStream

the InputStream to read from

Returns:XMLStreamReader

an instance of the XMLStreamReader

Exceptions
XMLStreamException:
if an error occurs
createXMLStreamReaderback to summary
public abstract XMLStreamReader createXMLStreamReader(String systemId, Reader reader) throws XMLStreamException

Create a new XMLStreamReader from a java.io.InputStream.

Parameters
systemId:String

the system ID of the stream

reader:Reader

the InputStream to read from

Returns:XMLStreamReader

an instance of the XMLStreamReader

Exceptions
XMLStreamException:
if an error occurs
getEventAllocatorback to summary
public abstract XMLEventAllocator getEventAllocator()

Gets the allocator used by streams created with this factory

Returns:XMLEventAllocator

an instance of the XMLEventAllocator

getPropertyback to summary
public abstract Object getProperty(String name) throws IllegalArgumentException

Get the value of a feature/property from the underlying implementation

Parameters
name:String

The name of the property (may not be null)

Returns:Object

The value of the property

Exceptions
IllegalArgumentException:
if the property is not supported
getXMLReporterback to summary
public abstract XMLReporter getXMLReporter()

The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

Returns:XMLReporter

an instance of the XMLReporter

getXMLResolverback to summary
public abstract XMLResolver getXMLResolver()

The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

Returns:XMLResolver

an instance of the XMLResolver

isPropertySupportedback to summary
public abstract boolean isPropertySupported(String name)

Query the set of properties that this factory supports.

Parameters
name:String

The name of the property (may not be null)

Returns:boolean

true if the property is supported and false otherwise

newDefaultFactoryback to summary
public static XMLInputFactory newDefaultFactory()

Creates a new instance of the XMLInputFactory builtin system-default implementation.

Returns:XMLInputFactory

A new instance of the XMLInputFactory builtin system-default implementation.

Since
9
newFactoryback to summary
public static XMLInputFactory newFactory() throws FactoryConfigurationError

Creates a new instance of the factory. This method uses the JAXP Lookup Mechanism 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.

Returns:XMLInputFactory

an instance of the XMLInputFactory

Exceptions
FactoryConfigurationError:
in case of service configuration error or if the implementation is not available or cannot be instantiated.
newFactoryback to summary
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.

This method uses the following ordered lookup procedure to determine the XMLInputFactory implementation class to load:

  • Use the value of the system property identified by factoryId.

  • Use the value of the property factoryId set in the configuration file, jaxp.properties by default. If the file exists and the property factoryId is specified in the file, its value will be used as the implementation class.

  • If factoryId is "javax.xml.stream.XMLInputFactory", use the service-provider loading facility, defined by the java.util.ServiceLoader class, to attempt to locate and load an implementation of the service using the specified ClassLoader. If classLoader is null, the default loading mechanism will apply: That is, the service-provider loading facility will use the current thread's context class loader to attempt to load the service. If the context class loader is null, the system class loader will be used.

  • Otherwise, throws a FactoryConfigurationError.

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.

API Note

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.

Parameters
factoryId:String

Name of the factory to find, same as a property name

classLoader:ClassLoader

classLoader to use

Returns:XMLInputFactory

the factory implementation

Exceptions
FactoryConfigurationError:
  • in case of service configuration error or if the implementation is not available or cannot be instantiated.
  • if an instance of this factory cannot be loaded
newInstanceback to summary
public static XMLInputFactory newInstance() throws FactoryConfigurationError

Creates a new instance of the factory in exactly the same manner as the newFactory() method.

Returns:XMLInputFactory

an instance of the XMLInputFactory

Exceptions
FactoryConfigurationError:
if an instance of this factory cannot be loaded
newInstanceback to summary
public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader) throws FactoryConfigurationError

Deprecated

since 1.7.

This method has been deprecated to maintain API consistency. All newInstance methods have been replaced with corresponding newFactory methods. The replacement newFactory(java.lang.String, java.lang.ClassLoader) method defines no changes in behavior.

Create a new instance of the factory.

Parameters
factoryId:String

Name of the factory to find, same as a property name

classLoader:ClassLoader

classLoader to use

Returns:XMLInputFactory

the factory implementation

Annotations
@Deprecated
since:1.7
Exceptions
FactoryConfigurationError:
if an instance of this factory cannot be loaded
setEventAllocatorback to summary
public abstract void setEventAllocator(XMLEventAllocator allocator)

Set a user defined event allocator for events

Parameters
allocator:XMLEventAllocator

the user defined allocator

setPropertyback to summary
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 javax.xml.XMLConstants#ACCESS_EXTERNAL_DTD property.

Parameters
name:String

The name of the property (may not be null)

value:Object

The value of the property

Exceptions
IllegalArgumentException:
if the property is not supported
setXMLReporterback to summary
public abstract void setXMLReporter(XMLReporter reporter)

The reporter that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

Parameters
reporter:XMLReporter

the resolver to use to report non fatal errors

setXMLResolverback to summary
public abstract void setXMLResolver(XMLResolver resolver)

The resolver that will be set on any XMLStreamReader or XMLEventReader created by this factory instance.

Parameters
resolver:XMLResolver

the resolver to use to resolve references