01: /*
02: * This file is part of PFIXCORE.
03: *
04: * PFIXCORE is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU Lesser General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * PFIXCORE is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with PFIXCORE; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: *
18: */
19:
20: package de.schlund.pfixcore.webservice.utils;
21:
22: import java.io.CharArrayWriter;
23: import java.io.IOException;
24: import java.io.Writer;
25:
26: /**
27: * @author mleidig@schlund.de
28: */
29: public class RecordingWriter extends Writer {
30:
31: CharArrayWriter chars;
32: Writer writer;
33:
34: public RecordingWriter(Writer writer) {
35: this .writer = writer;
36: chars = new CharArrayWriter();
37: }
38:
39: public char[] getCharacters() {
40: return chars.toCharArray();
41: }
42:
43: public Writer append(char c) throws IOException {
44: chars.append(c);
45: return writer.append(c);
46: }
47:
48: public Writer append(CharSequence csq, int start, int end)
49: throws IOException {
50: chars.append(csq, start, end);
51: return writer.append(csq, start, end);
52: }
53:
54: public Writer append(CharSequence csq) throws IOException {
55: chars.append(csq);
56: return writer.append(csq);
57: }
58:
59: public void close() throws IOException {
60: writer.close();
61: }
62:
63: public void flush() throws IOException {
64: writer.flush();
65: }
66:
67: public void write(char[] cbuf, int off, int len) throws IOException {
68: chars.write(cbuf, off, len);
69: writer.write(cbuf, off, len);
70: }
71:
72: public void write(char[] cbuf) throws IOException {
73: chars.write(cbuf);
74: writer.write(cbuf);
75: }
76:
77: public void write(int c) throws IOException {
78: chars.write(c);
79: writer.write(c);
80: }
81:
82: public void write(String str, int off, int len) throws IOException {
83: chars.write(str, off, len);
84: writer.write(str, off, len);
85: }
86:
87: public void write(String str) throws IOException {
88: chars.write(str);
89: writer.write(str);
90: }
91:
92: }
|