// $Id: Output.java,v 1.5 2004/03/05 17:05:44 m31 Exp $
//
// This file is part of the program suite "Principia Mathematica II"
// which is a working prototype for the main project:
// "Hilbert II" - http://www.qedeq.org
//
// Copyright 2001-2004  Michael Meyling <mime@qedeq.org>.
//
// "Principia Mathematica II" is free software; you can redistribute
// it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation; either
// version 2 of the License, or (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.

package com.meyling.principia.io;


/**
 * Output wrapping.
 * @version $Revision: 1.5 $
 * @author  Michael Meyling
 */
public class Output {

    /** char marking end of data */
    private final static char EOF = Character.MAX_VALUE;

    /** char marking end of input line */
    private final static char CR = '\015';

    /** where the output goes */
    private final StringBuffer destination;


    /**
     * Constructs a new output object, based on a
     * <code>StringBuffer</code>.
     *
     * @param   destination to write to
     */
    public Output(final StringBuffer destination) {
        if (destination == null) {
            throw new IllegalArgumentException(
                IoConstants.NULLPOINTER_PARAMETER);
        }
        this.destination = destination;
    }


    /**
     * Append new line to output.
     */
    public final void writeln() {
        destination.append('\n');
    }


    /**
     * Append data to output.
     *
     * @param   data    data to append
     */
    public final void write(final String data) {
        destination.append(data);
    }


    /**
     * Append data to output.
     *
     * @param   data    data to append
     */
    public final void writeln(final String data) {
        destination.append(data).append('\n');
    }


    /**
     * Append data to output.
     *
     * @param   data    data to append
     */
    public final void write(final int data) {
        destination.append(data);
    }


    /**
     * Append data to output.
     *
     * @param   data    data to append
     */
    public final void writeln(final int data) {
        destination.append(data).append('\n');
    }


    /**
     * Append character to output.
     *
     * @param   c    character to append
     */
    public final void write(final char c) {
        destination.append(c);
    }


    /**
     * Append character to output.
     *
     * @param   c    character to append
     */
    public final void writeln(final char c) {
        destination.append(c).append('\n');
    }


    /**
     * Append string representation of object to output.
     *
     * @param   data    this object will be written to output
     */
    public final void write(final Object data) {
        destination.append(data.toString());
    }


    /**
     * Append string representation of object to output.
     *
     * @param   data    this object will be written to output
     */
    public final void writeln(final Object data) {
        destination.append(data.toString()).append('\n');
    }



}
