javax.xml.stream
Class XMLOutputFactory

java.lang.Object
  extended byjavax.xml.stream.XMLOutputFactory

public abstract class XMLOutputFactory
extends java.lang.Object

Defines an abstract implementation of a factory for getting XMLEventWriters and XMLStreamWriters. The following table defines the standard properties that must be supported by each implementation of this specification.

Configuration parameters
Property Name Behavior Return type Default Value Required
javax.xml.stream.isPrefixDefaultingdefaults prefixes on the output sideBooleanFalseYes

See Also:
XMLInputFactory, XMLEventWriter, XMLStreamWriter

Field Summary
static java.lang.String IS_PREFIX_DEFAULTING
          Property used to set prefix defaulting on the output side
 
Constructor Summary
protected XMLOutputFactory()
           
 
Method Summary
abstract  XMLEventWriter createXMLEventWriter(java.io.OutputStream stream)
          Create a new XMLEventWriter that writes to a stream
abstract  XMLEventWriter createXMLEventWriter(java.io.OutputStream stream, java.lang.String encoding)
          Create a new XMLEventWriter that writes to a stream
abstract  XMLEventWriter createXMLEventWriter(java.io.Writer stream)
          Create a new XMLEventWriter that writes to a writer
abstract  XMLStreamWriter createXMLStreamWriter(java.io.OutputStream stream)
          Create a new XMLStreamWriter that writes to a stream
abstract  XMLStreamWriter createXMLStreamWriter(java.io.OutputStream stream, java.lang.String encoding)
          Create a new XMLStreamWriter that writes to a stream
abstract  XMLStreamWriter createXMLStreamWriter(java.io.Writer stream)
          Create a new XMLStreamWriter that writes to a writer
abstract  java.lang.Object getProperty(java.lang.String name)
          Get a feature/property on the underlying implementation
abstract  boolean isPrefixDefaulting()
          Indicates if this factory is configured to create streams that default namespace prefixes.
abstract  boolean isPropertySupported(java.lang.String name)
          Query the set of properties that this factory supports.
static XMLOutputFactory newInstance()
          Create a new instance of the factory.
static XMLInputFactory newInstance(java.lang.String factoryId, java.lang.ClassLoader classLoader)
          Create a new instance of the factory
abstract  void setPrefixDefaulting(boolean value)
          Specifies that the writer default namespace prefix declarations.
abstract  void setProperty(java.lang.String name, java.lang.Object value)
          Allows the user to set specific features/properties on the underlying implementation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

IS_PREFIX_DEFAULTING

public static final java.lang.String IS_PREFIX_DEFAULTING
Property used to set prefix defaulting on the output side

See Also:
Constant Field Values
Constructor Detail

XMLOutputFactory

protected XMLOutputFactory()
Method Detail

newInstance

public static XMLOutputFactory newInstance()
                                    throws FactoryConfigurationError
Create a new instance of the factory.

Throws:
FactoryConfigurationError - if an instance of this factory cannot be loaded

newInstance

public static XMLInputFactory newInstance(java.lang.String factoryId,
                                          java.lang.ClassLoader classLoader)
                                   throws FactoryConfigurationError
Create a new instance of the factory

Parameters:
factoryId - Name of the factory to find, same as a property name
classLoader - classLoader to use
Returns:
the factory implementation
Throws:
FactoryConfigurationError - if an instance of this factory cannot be loaded

createXMLStreamWriter

public abstract XMLStreamWriter createXMLStreamWriter(java.io.Writer stream)
                                               throws XMLStreamException
Create a new XMLStreamWriter that writes to a writer

Parameters:
stream - the writer to write to
Throws:
XMLStreamException

createXMLStreamWriter

public abstract XMLStreamWriter createXMLStreamWriter(java.io.OutputStream stream)
                                               throws XMLStreamException
Create a new XMLStreamWriter that writes to a stream

Parameters:
stream - the stream to write to
Throws:
XMLStreamException

createXMLStreamWriter

public abstract XMLStreamWriter createXMLStreamWriter(java.io.OutputStream stream,
                                                      java.lang.String encoding)
                                               throws XMLStreamException
Create a new XMLStreamWriter that writes to a stream

Parameters:
stream - the stream to write to
encoding - the encoding to use
Throws:
XMLStreamException

createXMLEventWriter

public abstract XMLEventWriter createXMLEventWriter(java.io.OutputStream stream)
                                             throws XMLStreamException
Create a new XMLEventWriter that writes to a stream

Parameters:
stream - the stream to write to
Throws:
XMLStreamException

createXMLEventWriter

public abstract XMLEventWriter createXMLEventWriter(java.io.OutputStream stream,
                                                    java.lang.String encoding)
                                             throws XMLStreamException
Create a new XMLEventWriter that writes to a stream

Parameters:
stream - the stream to write to
encoding - the encoding to use
Throws:
XMLStreamException

createXMLEventWriter

public abstract XMLEventWriter createXMLEventWriter(java.io.Writer stream)
                                             throws XMLStreamException
Create a new XMLEventWriter that writes to a writer

Parameters:
stream - the stream to write to
Throws:
XMLStreamException

setProperty

public abstract void setProperty(java.lang.String name,
                                 java.lang.Object value)
                          throws java.lang.IllegalArgumentException
Allows the user to set specific features/properties on the underlying implementation.

Parameters:
name - The name of the property
value - The value of the property
Throws:
java.lang.IllegalArgumentException - if the property is not supported

getProperty

public abstract java.lang.Object getProperty(java.lang.String name)
                                      throws java.lang.IllegalArgumentException
Get a feature/property on the underlying implementation

Parameters:
name - The name of the property
Returns:
The value of the property
Throws:
java.lang.IllegalArgumentException - if the property is not supported

isPrefixDefaulting

public abstract boolean isPrefixDefaulting()
Indicates if this factory is configured to create streams that default namespace prefixes.

Returns:
true if the factory is prefix defaulting and fals otherwise

isPropertySupported

public abstract boolean isPropertySupported(java.lang.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

setPrefixDefaulting

public abstract void setPrefixDefaulting(boolean value)
Specifies that the writer default namespace prefix declarations. The default value is false. If a writer isPrefixDefaulting it will create a namespace declaration on the current StartElement for any attribute that does not currently have a namespace declaration in scope. If the StartElement has a uri but no prefix specified a prefix will be assigned, if the prefix has not been declared in a parent of the current StartElement it will be declared on the current StartElement. If the defaultNamespace is bound and in scope and the default namespace matches the URI of the attribute or StartElement QName no prefix will be assigned. This is a convenvience method for setProperty("javax.xml.stream.isPrefixDefaulting",new Boolean(true|false));

Parameters:
value - the value to set prefix defaulting to (default is false)