001/*
002 * #%L
003 * Netarchivesuite - common - test
004 * %%
005 * Copyright (C) 2005 - 2014 The Royal Danish Library, the Danish State and University Library,
006 *             the National Library of France and the Austrian National Library.
007 * %%
008 * This program is free software: you can redistribute it and/or modify
009 * it under the terms of the GNU Lesser General Public License as
010 * published by the Free Software Foundation, either version 2.1 of the
011 * License, or (at your option) any later version.
012 * 
013 * This program is distributed in the hope that it will be useful,
014 * but WITHOUT ANY WARRANTY; without even the implied warranty of
015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016 * GNU General Lesser Public License for more details.
017 * 
018 * You should have received a copy of the GNU General Lesser Public
019 * License along with this program.  If not, see
020 * <http://www.gnu.org/licenses/lgpl-2.1.html>.
021 * #L%
022 */
023
024package dk.netarkivet.common.webinterface;
025
026import java.io.IOException;
027import java.io.StringWriter;
028
029import javax.servlet.jsp.JspWriter;
030
031/** JSP writer that simply writes to a public string writer. */
032public class JspWriterMockup extends JspWriter {
033    public StringWriter sw = new StringWriter();
034
035    public JspWriterMockup() {
036        super(Integer.MAX_VALUE, false);
037    }
038
039    public void newLine() throws IOException {
040        sw.append('\n');
041    }
042
043    public void print(boolean b) throws IOException {
044        sw.append(Boolean.toString(b));
045    }
046
047    public void print(char c) throws IOException {
048        sw.append(Character.toString(c));
049    }
050
051    public void print(int i) throws IOException {
052        sw.append(Integer.toString(i));
053    }
054
055    public void print(long l) throws IOException {
056        sw.append(Long.toString(l));
057    }
058
059    public void print(float v) throws IOException {
060        sw.append(Float.toString(v));
061    }
062
063    public void print(double v) throws IOException {
064        sw.append(Double.toString(v));
065    }
066
067    public void print(char[] chars) throws IOException {
068        sw.append(new String(chars));
069    }
070
071    public void print(String string) throws IOException {
072        sw.append(string);
073    }
074
075    public void print(Object object) throws IOException {
076        sw.append(object.toString());
077    }
078
079    public void println() throws IOException {
080        sw.append('\n');
081    }
082
083    public void println(boolean b) throws IOException {
084        print(b);
085        println();
086    }
087
088    public void println(char c) throws IOException {
089        print(c);
090        println();
091    }
092
093    public void println(int i) throws IOException {
094        print(i);
095        println();
096    }
097
098    public void println(long l) throws IOException {
099        print(l);
100        println();
101    }
102
103    public void println(float v) throws IOException {
104        print(v);
105        println();
106    }
107
108    public void println(double v) throws IOException {
109        print(v);
110        println();
111    }
112
113    public void println(char[] chars) throws IOException {
114        print(chars);
115        println();
116    }
117
118    public void println(String string) throws IOException {
119        print(string);
120        println();
121    }
122
123    public void println(Object object) throws IOException {
124        print(object);
125        println();
126    }
127
128    public void clear() throws IOException {
129        sw = new StringWriter();
130    }
131
132    public void clearBuffer() throws IOException {
133        sw = new StringWriter();
134    }
135
136    public void write(char cbuf[], int off, int len) throws IOException {
137        sw.append(new String(cbuf, off, len));
138    }
139
140    public void flush() throws IOException {
141        sw.flush();
142    }
143
144    public void close() throws IOException {
145        sw.close();
146    }
147
148    public int getRemaining() {
149        return Integer.MAX_VALUE;
150    }
151}