001: package com.mockrunner.mock.web;
002:
003: import java.io.IOException;
004: import java.io.Reader;
005: import java.io.StringReader;
006: import java.io.Writer;
007:
008: import javax.servlet.jsp.JspWriter;
009: import javax.servlet.jsp.tagext.BodyContent;
010:
011: /**
012: * Mock implementation of <code>BodyContent</code>.
013: */
014: public class MockBodyContent extends BodyContent {
015: private MockJspWriter body;
016:
017: public MockBodyContent(JspWriter writer) {
018: super (writer);
019: body = new MockJspWriter();
020: }
021:
022: public String getOutputAsString() {
023: return getString();
024: }
025:
026: public String toString() {
027: return getString();
028: }
029:
030: public Reader getReader() {
031: return new StringReader(getString());
032: }
033:
034: public String getString() {
035: return body.getOutputAsString();
036: }
037:
038: public void writeOut(Writer writer) throws IOException {
039: writer.write(getString());
040: }
041:
042: public void clearBody() {
043: body = new MockJspWriter();
044: }
045:
046: public void newLine() throws IOException {
047: body.newLine();
048: }
049:
050: public void print(boolean arg0) throws IOException {
051: body.print(arg0);
052: }
053:
054: public void print(char arg0) throws IOException {
055: body.print(arg0);
056: }
057:
058: public void print(int arg0) throws IOException {
059: body.print(arg0);
060: }
061:
062: public void print(long arg0) throws IOException {
063: body.print(arg0);
064: }
065:
066: public void print(float arg0) throws IOException {
067: body.print(arg0);
068: }
069:
070: public void print(double arg0) throws IOException {
071: body.print(arg0);
072: }
073:
074: public void print(char[] arg0) throws IOException {
075: body.print(arg0);
076: }
077:
078: public void print(String arg0) throws IOException {
079: body.print(arg0);
080: }
081:
082: public void print(Object arg0) throws IOException {
083: body.print(arg0);
084: }
085:
086: public void println() throws IOException {
087: body.println();
088: }
089:
090: public void println(boolean arg0) throws IOException {
091: body.println(arg0);
092: }
093:
094: public void println(char arg0) throws IOException {
095: body.println(arg0);
096: }
097:
098: public void println(int arg0) throws IOException {
099: body.println(arg0);
100: }
101:
102: public void println(long arg0) throws IOException {
103: body.println(arg0);
104: }
105:
106: public void println(float arg0) throws IOException {
107: body.println(arg0);
108: }
109:
110: public void println(double arg0) throws IOException {
111: body.println(arg0);
112: }
113:
114: public void println(char[] arg0) throws IOException {
115: body.println(arg0);
116: }
117:
118: public void println(String arg0) throws IOException {
119: body.println(arg0);
120: }
121:
122: public void println(Object arg0) throws IOException {
123: body.println(arg0);
124: }
125:
126: public void clear() throws IOException {
127: body.clear();
128: }
129:
130: public void clearBuffer() throws IOException {
131: body.clearBuffer();
132: }
133:
134: public void close() throws IOException {
135: body.close();
136: }
137:
138: public int getRemaining() {
139: return body.getRemaining();
140: }
141:
142: public void write(char[] cbuf, int off, int len) throws IOException {
143: body.write(cbuf, off, len);
144: }
145: }
|