FileDocCategorySizeDatePackage
TransletOutputHandlerFactory.javaAPI DocJava SE 5 API6480Fri Aug 26 14:55:40 BST 2005com.sun.org.apache.xalan.internal.xsltc.runtime.output

TransletOutputHandlerFactory

public class TransletOutputHandlerFactory extends Object
author
Santiago Pericas-Geertsen

Fields Summary
public static final int
STREAM
public static final int
SAX
public static final int
DOM
private String
_encoding
private String
_method
private int
_outputType
private OutputStream
_ostream
private Writer
_writer
private Node
_node
private int
_indentNumber
private ContentHandler
_handler
private LexicalHandler
_lexHandler
Constructors Summary
Methods Summary
public org.w3c.dom.NodegetNode()

	return (_handler instanceof SAX2DOM) ? ((SAX2DOM)_handler).getDOM() 
	   : null;
    
public com.sun.org.apache.xml.internal.serializer.SerializationHandlergetSerializationHandler()

        SerializationHandler result = null;
        switch (_outputType)
        {
            case STREAM :

                if (_method == null)
                {
                    result = new ToUnknownStream();
                }
                else if (_method.equalsIgnoreCase("xml"))
                {

                    result = new ToXMLStream();

                }
                else if (_method.equalsIgnoreCase("html"))
                {

                    result = new ToHTMLStream();

                }
                else if (_method.equalsIgnoreCase("text"))
                {

                    result = new ToTextStream();

                }

                if (result != null && _indentNumber >= 0)
                {
                    result.setIndentAmount(_indentNumber);
                }

                result.setEncoding(_encoding);

                if (_writer != null)
                {
                    result.setWriter(_writer);
                }
                else
                {
                    result.setOutputStream(_ostream);
                }
                return result;

            case DOM :
                _handler = (_node != null) ? new SAX2DOM(_node) : new SAX2DOM();
                _lexHandler = (LexicalHandler) _handler;
                // falls through
            case SAX :
                if (_method == null)
                {
                    _method = "xml"; // default case
                }

                if (_method.equalsIgnoreCase("xml"))
                {

                    if (_lexHandler == null)
                    {
                        result = new ToXMLSAXHandler(_handler, _encoding);
                    }
                    else
                    {
                        result =
                            new ToXMLSAXHandler(
                                _handler,
                                _lexHandler,
                                _encoding);
                    }

                }
                else if (_method.equalsIgnoreCase("html"))
                {

                    if (_lexHandler == null)
                    {
                        result = new ToHTMLSAXHandler(_handler, _encoding);
                    }
                    else
                    {
                        result =
                            new ToHTMLSAXHandler(
                                _handler,
                                _lexHandler,
                                _encoding);
                    }

                }
                else if (_method.equalsIgnoreCase("text"))
                {

                    if (_lexHandler == null)
                    {
                        result = new ToTextSAXHandler(_handler, _encoding);
                    }
                    else
                    {
                        result =
                            new ToTextSAXHandler(
                                _handler,
                                _lexHandler,
                                _encoding);
                    }

                }
                return result;
        }
        return null;
    
public static com.sun.org.apache.xalan.internal.xsltc.runtime.output.TransletOutputHandlerFactorynewInstance()


        
	return new TransletOutputHandlerFactory();
    
public voidsetEncoding(java.lang.String encoding)

	if (encoding != null) {
	    _encoding = encoding;
	}
    
public voidsetHandler(org.xml.sax.ContentHandler handler)

        _handler = handler;
    
public voidsetIndentNumber(int value)

	_indentNumber = value;
    
public voidsetLexicalHandler(org.xml.sax.ext.LexicalHandler lex)

	_lexHandler = lex;
    
public voidsetNode(org.w3c.dom.Node node)

	_node = node;
    
public voidsetOutputMethod(java.lang.String method)

	_method = method;
    
public voidsetOutputStream(java.io.OutputStream ostream)

	_ostream = ostream;
    
public voidsetOutputType(int outputType)

	_outputType = outputType;
    
public voidsetWriter(java.io.Writer writer)

	_writer = writer;