class MessageOutputStream implements AutoCloseable {

	public ContentHandler asContentHandler() throws StreamingException {
		if (requestStream instanceof ContentHandler) {
			if (log.isDebugEnabled()) log.debug(getLogPrefix()+"returning ContentHandler as ContentHandler");
			return (ContentHandler) requestStream;
		}
		if (requestStream instanceof OutputStream) {
			if (log.isDebugEnabled()) log.debug(getLogPrefix()+"returning OutputStream as ContentHandler");
			XmlWriter xmlWriter = new XmlWriter((OutputStream) requestStream);
			xmlWriter.setIncludeXmlDeclaration(true);
			return xmlWriter;
		}
		if (requestStream instanceof Writer) {
			if (log.isDebugEnabled()) log.debug(getLogPrefix()+"returning Writer as ContentHandler");
			return new XmlWriter((Writer) requestStream);
		}
		return null;

	}

	protected  MessageOutputStream(INamedObject owner, IForwardTarget next);
	protected  MessageOutputStream(INamedObject owner, MessageOutputStream nextStream);
	public  MessageOutputStream(INamedObject owner, OutputStream stream, IForwardTarget next);
	public  MessageOutputStream(INamedObject owner, OutputStream stream, MessageOutputStream nextStream);
	public  MessageOutputStream(INamedObject owner, Writer writer, IForwardTarget next);
	public  MessageOutputStream(INamedObject owner, Writer writer, MessageOutputStream nextStream);
	public  MessageOutputStream(INamedObject owner, ContentHandler handler, IForwardTarget next, ThreadLifeCycleEventListener<Object> threadLifeCycleEventListener, IPipeLineSession session);
	public  MessageOutputStream(INamedObject owner, ContentHandler handler, MessageOutputStream nextStream, ThreadLifeCycleEventListener<Object> threadLifeCycleEventListener, IPipeLineSession session);

}