javax.xml.stream

Class XMLOutputFactory

public abstract class XMLOutputFactory extends Object

Factory for obtaining XML stream and event writers for various kinds of output sink.

Configuration

Name Description Type Default Required
javax.xml.stream.isRepairingNamespaces default namespace prefixes Boolean Boolean.FALSE yes
Field Summary
static StringIS_REPAIRING_NAMESPACES
Property used to control whether to default namespace prefixes.
Constructor Summary
protected XMLOutputFactory()
Method Summary
abstract XMLEventWritercreateXMLEventWriter(Result result)
Creates a new event writer.
abstract XMLEventWritercreateXMLEventWriter(OutputStream stream)
Creates a new event writer.
abstract XMLEventWritercreateXMLEventWriter(OutputStream stream, String encoding)
Creates a new event writer.
abstract XMLEventWritercreateXMLEventWriter(Writer stream)
Creates a new event writer.
abstract XMLStreamWritercreateXMLStreamWriter(Writer stream)
Creates a new stream writer.
abstract XMLStreamWritercreateXMLStreamWriter(OutputStream stream)
Creates a new stream writer.
abstract XMLStreamWritercreateXMLStreamWriter(OutputStream stream, String encoding)
Creates a new stream writer.
abstract XMLStreamWritercreateXMLStreamWriter(Result result)
Creates a new stream writer.
abstract ObjectgetProperty(String name)
Returns the implementation-specific property of the given name.
abstract booleanisPropertySupported(String name)
Indicates whether the specified property is supported.
static XMLOutputFactorynewInstance()
Creates a new output factory.
static XMLInputFactorynewInstance(String factoryId, ClassLoader classLoader)
Creates a new input factory.
abstract voidsetProperty(String name, Object value)
Sets the implementation-specific property of the given name.

Field Detail

IS_REPAIRING_NAMESPACES

public static final String IS_REPAIRING_NAMESPACES
Property used to control whether to default namespace prefixes. If true, the writer will create a namespace declaration for any attribute that doesn't have a namespace declaration in scope.

Constructor Detail

XMLOutputFactory

protected XMLOutputFactory()

Method Detail

createXMLEventWriter

public abstract XMLEventWriter createXMLEventWriter(Result result)
Creates a new event writer.

Throws: UnsupportedOperationException if this method is not supported

createXMLEventWriter

public abstract XMLEventWriter createXMLEventWriter(OutputStream stream)
Creates a new event writer.

createXMLEventWriter

public abstract XMLEventWriter createXMLEventWriter(OutputStream stream, String encoding)
Creates a new event writer.

createXMLEventWriter

public abstract XMLEventWriter createXMLEventWriter(Writer stream)
Creates a new event writer.

createXMLStreamWriter

public abstract XMLStreamWriter createXMLStreamWriter(Writer stream)
Creates a new stream writer.

createXMLStreamWriter

public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream)
Creates a new stream writer.

createXMLStreamWriter

public abstract XMLStreamWriter createXMLStreamWriter(OutputStream stream, String encoding)
Creates a new stream writer.

createXMLStreamWriter

public abstract XMLStreamWriter createXMLStreamWriter(Result result)
Creates a new stream writer.

Throws: UnsupportedOperationException if this method is not supported

getProperty

public abstract Object getProperty(String name)
Returns the implementation-specific property of the given name.

Throws: IllegalArgumentException if the property is not supported

isPropertySupported

public abstract boolean isPropertySupported(String name)
Indicates whether the specified property is supported.

newInstance

public static XMLOutputFactory newInstance()
Creates a new output factory. The implementation class to load is the first found in the following locations:
  1. the javax.xml.stream.XMLOutputFactory system property
  2. the above named property value in the $JAVA_HOME/lib/stax.properties file
  3. the class name specified in the META-INF/services/javax.xml.stream.XMLOutputFactory system resource
  4. the default factory class

newInstance

public static XMLInputFactory newInstance(String factoryId, ClassLoader classLoader)
Creates a new input factory. This appears to be an API design bug.

See Also: javax.xml.stream.XMLInputFactory.newInstance(String,ClassLoader)

setProperty

public abstract void setProperty(String name, Object value)
Sets the implementation-specific property of the given name.

Throws: IllegalArgumentException if the property is not supported