org.apache.xml.serializer
Class SerializerFactory

java.lang.Object
  extended by org.apache.xml.serializer.SerializerFactory

public final class SerializerFactory
extends java.lang.Object

This class is a public API, it is a factory for creating serializers. The properties object passed to the getSerializer() method should be created by the OutputPropertiesFactory. Although the properties object used to create a serializer does not need to be obtained from OutputPropertiesFactory, using this factory ensures that the default key/value properties are set for the given output "method".

The standard property keys supported are: "method", "version", "encoding", "omit-xml-declaration", "standalone", doctype-public", "doctype-system", "cdata-section-elements", "indent", "media-type". These property keys and their values are described in the XSLT recommendation, see XSLT 1.0 recommendation

The value of the "cdata-section-elements" property key is a whitespace separated list of elements. If the element is in a namespace then value is passed in this format: {uri}localName

The non-standard property keys supported are defined in OutputPropertiesFactory.

See Also:
OutputPropertiesFactory, Method, Serializer

Field Summary
private static java.util.Hashtable m_formats
          Associates output methods to default output formats.
 
Constructor Summary
private SerializerFactory()
          This constructor is private just to prevent the creation of such an object.
 
Method Summary
static Serializer getSerializer(java.util.Properties format)
          Returns a serializer for the specified output method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

m_formats

private static java.util.Hashtable m_formats
Associates output methods to default output formats.

Constructor Detail

SerializerFactory

private SerializerFactory()
This constructor is private just to prevent the creation of such an object.

Method Detail

getSerializer

public static Serializer getSerializer(java.util.Properties format)
Returns a serializer for the specified output method. The output method is specified by the value of the property associated with the "method" key. If no implementation exists that supports the specified output method an exception of some type will be thrown. For a list of the output "method" key values see Method.

Parameters:
format - The output format, minimally the "method" property must be set.
Returns:
A suitable serializer.
Throws:
java.lang.IllegalArgumentException - if method is null or an appropriate serializer can't be found
java.lang.Exception - if the class for the serializer is found but does not implement ContentHandler.
WrappedRuntimeException - if an exception is thrown while trying to find serializer