FileDocCategorySizeDatePackage
SerializerFactory.javaAPI DocApache Xerces 3.0.15464Fri Sep 14 20:33:52 BST 2007org.apache.xml.serialize

SerializerFactory

public abstract class SerializerFactory extends Object
deprecated
This class was deprecated in Xerces 2.9.0. It is recommended that new applications use the DOM Level 3 LSSerializer or JAXP's Transformation API for XML (TrAX) for serializing XML and HTML. See the Xerces documentation for more information.
version
$Revision: 558589 $ $Date: 2007-07-22 22:41:55 -0400 (Sun, 22 Jul 2007) $
author
Scott Boag
author
Assaf Arkin

Fields Summary
public static final String
FactoriesProperty
private static Hashtable
_factories
Constructors Summary
Methods Summary
public static org.apache.xml.serialize.SerializerFactorygetSerializerFactory(java.lang.String method)
Register a serializer factory, keyed by the given method string.

        return (SerializerFactory) _factories.get( method );
    
protected abstract java.lang.StringgetSupportedMethod()
Returns the method supported by this factory and used to register the factory. This call is required so factories can be added from a properties file by knowing only the class name. This method is protected, it is only required by this class but must be implemented in derived classes.

public abstract SerializermakeSerializer(OutputFormat format)
Create a new serializer based on the {@link OutputFormat}. If this method is used to create the serializer, the {@link Serializer#setOutputByteStream} or {@link Serializer#setOutputCharStream} methods must be called before serializing a document.

public abstract SerializermakeSerializer(java.io.Writer writer, OutputFormat format)
Create a new serializer, based on the {@link OutputFormat} and using the writer as the output character stream. If this method is used, the encoding property will be ignored.

public abstract SerializermakeSerializer(java.io.OutputStream output, OutputFormat format)
Create a new serializer, based on the {@link OutputFormat} and using the output byte stream and the encoding specified in the output format.

throws
UnsupportedEncodingException The specified encoding is not supported

public static voidregisterSerializerFactory(org.apache.xml.serialize.SerializerFactory factory)
Register a serializer factory, keyed by the given method string.


    
    
        SerializerFactory factory;
        String            list;
        StringTokenizer   token;
        String            className;

        // The default factories are always registered first,
        // any factory specified in the properties file and supporting
        // the same method will override the default factory.
        factory =  new SerializerFactoryImpl( Method.XML );
        registerSerializerFactory( factory );
        factory =  new SerializerFactoryImpl( Method.HTML );
        registerSerializerFactory( factory );
        factory =  new SerializerFactoryImpl( Method.XHTML );
        registerSerializerFactory( factory );
        factory =  new SerializerFactoryImpl( Method.TEXT );
        registerSerializerFactory( factory );

        list = SecuritySupport.getSystemProperty( FactoriesProperty );
        if ( list != null ) {
            token = new StringTokenizer( list, " ;,:" );
            while ( token.hasMoreTokens() ) {
                className = token.nextToken();
                try {
                    factory = (SerializerFactory) ObjectFactory.newInstance( className,
                        SerializerFactory.class.getClassLoader(), true);
                    if ( _factories.containsKey( factory.getSupportedMethod() ) )
                        _factories.put( factory.getSupportedMethod(), factory );
                } catch ( Exception except ) { }
            }
        }
    
        String method;

        synchronized ( _factories ) {
            method = factory.getSupportedMethod();
            _factories.put( method, factory );
        }