package com.atos.cocoon.action;

import java.io.IOException;
import java.io.StringReader;

import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.xml.XMLizable;
import org.apache.xerces.parsers.SAXParser;
import org.xml.sax.ContentHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;

/**
 * @author nl16036
 *
 * To change this generated comment edit the template variable "typecomment":
 * Window>Preferences>Java>Templates.
 * To enable and disable the creation of type comments go to
 * Window>Preferences>Java>Code Generation.
 */
public class MyMessage implements XMLizable {

	/**
	 * Constructor for XMLDocument.
	 */
	public MyMessage() {
		
		super();
	}
	
	public	void	setMessage(StringBuffer	message)	{
	
		_fragment	=	message;	
	}

	/**
	 * @see org.apache.cocoon.xml.XMLizable#toSAX(ContentHandler)
	 */
	public void toSAX(ContentHandler arg0)
		throws SAXException, ProcessingException {
			
			SAXParser	parser	=	new	SAXParser();
			parser.setContentHandler(arg0);
			
			StringReader	reader	=	new	StringReader(_fragment.toString());
			InputSource		source	=	new	InputSource(reader);
			

			try {
				parser.parse(source);
			}  catch (IOException e) {
			}

	}

	private	StringBuffer	_fragment	=	null;
}
