// ConsoleStream.java
//
// Created: November 2005
//
// This file is a component of the BioMoby project.
// Copyright Martin Senger (martin.senger@gmail.com).
//

package org.biomoby.service.dashboard;

import java.io.OutputStream;
import java.io.IOException;

/**
 * A simple stream writing data into given {@link CommonConsole}
 * component. <p>
 *
 * @author <A HREF="mailto:martin.senger@gmail.com">Martin Senger</A>
 * @version $Id: ConsoleStream.java,v 1.2 2006/02/20 05:51:10 senger Exp $
 */

public class ConsoleStream
     extends OutputStream {

    private boolean isErrorStream = false;
    private CommonConsole console;

    /*********************************************************************
     * A usual constructor. <p>
     *
     * @param console where to stream will write
     * @param isErrorStream true if the stream contains error messages
     * (so it can distinguish it by some colors, possibly)
     ********************************************************************/
    public ConsoleStream (CommonConsole console,
			  boolean isErrorStream) {
	super();
	this.isErrorStream = isErrorStream;
	this.console = console;
    }

    /*********************************************************************
     * TBD: I am still not sure - my code does not seem to be
     * optimalized. Anybody can help me and improve it?
     ********************************************************************/
    public void write (int b)
	throws IOException {

	String aChar = new Character((char)b).toString();
 	console.setText (aChar);
    }

}
