/*
 * JSPTem - use jsp's for all your templating!
 * Copyright (c) 2006, Paul Tuckey
 * All rights reserved.
 *
 * JSPTem is based on GNUJSP
 * Copyright (C) 1999, Yaroslav Faybishenko <yaroslav@cs.berkeley.edu>
 *
 * Each copy or derived work must preserve the copyright notice and this
 * notice unmodified.
 *
 * This program 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.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
package org.tuckey.jsptem.servlet;

import javax.servlet.jsp.JspWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.Writer;


public class JspTemJspWriter extends JspWriter {

    PrintWriter writer;

    protected JspTemJspWriter(int i, boolean b) {
        super(i, b);
    }

    public JspTemJspWriter(Writer writer) {
        super(0, true);
        this.writer = new PrintWriter(writer);
    }

    public int getRemaining() {
        return 0;
    }

    public void clear() throws IOException {
        //
    }

    public void clearBuffer() throws IOException {

    }

    public void close() throws IOException {
        writer.close();
    }

    /**
     * Write a portion of an array of characters.
     *
     * @param cbuf Array of characters
     * @param off  Offset from which to start writing characters
     * @param len  Number of characters to write
     * @throws java.io.IOException If an I/O error occurs
     */
    public void write(char cbuf[], int off, int len) throws IOException {
        writer.write(cbuf, off, len);
    }

    public void flush() throws IOException {
        writer.flush();
    }

    public void newLine() throws IOException {
        writer.println();
    }

    public void println() throws IOException {
        writer.println();
    }

    public void print(char c) throws IOException {
        writer.print(c);
    }

    public void println(char c) throws IOException {
        writer.println(c);
    }

    public void print(double v) throws IOException {
        writer.print(v);
    }

    public void println(double v) throws IOException {
        writer.println(v);
    }

    public void print(float v) throws IOException {
        writer.print(v);
    }

    public void println(float v) throws IOException {
        writer.println(v);
    }

    public void print(int i) throws IOException {
        writer.print(i);
    }

    public void println(int i) throws IOException {
        writer.println(i);
    }

    public void print(long l) throws IOException {
        writer.print(l);
    }

    public void println(long l) throws IOException {
        writer.println(l);
    }

    public void print(boolean b) throws IOException {
        writer.print(b);
    }

    public void println(boolean b) throws IOException {
        writer.println(b);
    }

    public void print(char[] chars) throws IOException {
        writer.print(chars);
    }

    public void println(char[] chars) throws IOException {
        writer.println(chars);
    }

    public void print(Object object) throws IOException {
        writer.print(object);
    }

    public void println(Object object) throws IOException {
        writer.println(object);
    }

    public void print(String string) throws IOException {
        writer.print(string);
    }

    public void println(String string) throws IOException {
        writer.println(string);
    }

    public boolean isAutoFlush() {
        return super.isAutoFlush();    //To change body of overridden methods use File | Settings | File Templates.
    }

    public int getBufferSize() {
        return super.getBufferSize();    //To change body of overridden methods use File | Settings | File Templates.
    }

    /**
     * Write a single character.  The character to be written is contained in
     * the 16 low-order bits of the given integer value; the 16 high-order bits
     * are ignored.
     * <p/>
     * <p> Subclasses that intend to support efficient single-character output
     * should override this method.
     *
     * @param c int specifying a character to be written.
     * @throws java.io.IOException If an I/O error occurs
     */
    public void write(int c) throws IOException {
        super.write(c);
    }

    /**
     * Write an array of characters.
     *
     * @param cbuf Array of characters to be written
     * @throws java.io.IOException If an I/O error occurs
     */
    public void write(char cbuf[]) throws IOException {
        super.write(cbuf);
    }

    /**
     * Write a string.
     *
     * @param str String to be written
     * @throws java.io.IOException If an I/O error occurs
     */
    public void write(String str) throws IOException {
        super.write(str);
    }

    /**
     * Write a portion of a string.
     *
     * @param str A String
     * @param off Offset from which to start writing characters
     * @param len Number of characters to write
     * @throws java.io.IOException If an I/O error occurs
     */
    public void write(String str, int off, int len) throws IOException {
        super.write(str, off, len);
    }

    /**
     * Appends the specified character sequence to this writer.
     * <p/>
     * <p> An invocation of this method of the form <tt>out.append(csq)</tt>
     * behaves in exactly the same way as the invocation
     * <p/>
     * <pre>
     *     out.write(csq.toString()) </pre>
     * <p/>
     * <p> Depending on the specification of <tt>toString</tt> for the
     * character sequence <tt>csq</tt>, the entire sequence may not be
     * appended. For instance, invoking the <tt>toString</tt> method of a
     * character buffer will return a subsequence whose content depends upon
     * the buffer's position and limit.
     *
     * @param csq The character sequence to append.  If <tt>csq</tt> is
     *            <tt>null</tt>, then the four characters <tt>"null"</tt> are
     *            appended to this writer.
     * @return This writer
     * @throws java.io.IOException If an I/O error occurs
     * @since 1.5
     */
    public Writer append(CharSequence csq) throws IOException {
        return super.append(csq);
    }

    /**
     * Appends a subsequence of the specified character sequence to this writer.
     * <tt>Appendable</tt>.
     * <p/>
     * <p> An invocation of this method of the form <tt>out.append(csq, start,
     * end)</tt> when <tt>csq</tt> is not <tt>null</tt> behaves in exactly the
     * same way as the invocation
     * <p/>
     * <pre>
     *     out.write(csq.subSequence(start, end).toString()) </pre>
     *
     * @param csq   The character sequence from which a subsequence will be
     *              appended.  If <tt>csq</tt> is <tt>null</tt>, then characters
     *              will be appended as if <tt>csq</tt> contained the four
     *              characters <tt>"null"</tt>.
     * @param start The index of the first character in the subsequence
     * @param end   The index of the character following the last character in the
     *              subsequence
     * @return This writer
     * @throws IndexOutOfBoundsException If <tt>start</tt> or <tt>end</tt> are negative, <tt>start</tt>
     *                                   is greater than <tt>end</tt>, or <tt>end</tt> is greater than
     *                                   <tt>csq.length()</tt>
     * @throws java.io.IOException       If an I/O error occurs
     * @since 1.5
     */
    public Writer append(CharSequence csq, int start, int end) throws IOException {
        return super.append(csq, start, end);
    }

    /**
     * Appends the specified character to this writer.
     * <p/>
     * <p> An invocation of this method of the form <tt>out.append(c)</tt>
     * behaves in exactly the same way as the invocation
     * <p/>
     * <pre>
     *     out.write(c) </pre>
     *
     * @param c The 16-bit character to append
     * @return This writer
     * @throws java.io.IOException If an I/O error occurs
     * @since 1.5
     */
    public Writer append(char c) throws IOException {
        return super.append(c);
    }
}
