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    {
016        private MockJspWriter body;
017        
018        public MockBodyContent(JspWriter writer)
019        {
020            super(writer);
021            body = new MockJspWriter();
022        }
023        
024        public String getOutputAsString()
025        {
026            return getString();
027        }
028    
029        public String toString()
030        {
031            return getString();
032        }
033    
034        public Reader getReader()
035        {
036            return new StringReader(getString());
037        }
038    
039        public String getString()
040        {
041            return body.getOutputAsString();
042        }
043    
044        public void writeOut(Writer writer) throws IOException
045        {
046            writer.write(getString());
047        }
048        
049        public void clearBody()
050        {
051            body = new MockJspWriter();
052        }
053    
054        public void newLine() throws IOException
055        {
056            body.newLine();
057        }
058    
059        public void print(boolean arg0) throws IOException
060        {
061            body.print(arg0);
062        }
063    
064        public void print(char arg0) throws IOException
065        {
066            body.print(arg0);
067        }
068    
069        public void print(int arg0) throws IOException
070        {
071            body.print(arg0);
072        }
073    
074        public void print(long arg0) throws IOException
075        {
076            body.print(arg0);
077        }
078    
079        public void print(float arg0) throws IOException
080        {
081            body.print(arg0);
082        }
083    
084        public void print(double arg0) throws IOException
085        {
086            body.print(arg0);
087        }
088    
089        public void print(char[] arg0) throws IOException
090        {
091            body.print(arg0);
092        }
093    
094        public void print(String arg0) throws IOException
095        {
096            body.print(arg0);
097        }
098    
099        public void print(Object arg0) throws IOException
100        {
101            body.print(arg0);
102        }
103    
104        public void println() throws IOException
105        {
106            body.println();
107        }
108    
109        public void println(boolean arg0) throws IOException
110        {
111            body.println(arg0);
112        }
113    
114        public void println(char arg0) throws IOException
115        {
116            body.println(arg0);
117        }
118    
119        public void println(int arg0) throws IOException
120        {
121            body.println(arg0);
122        }
123    
124        public void println(long arg0) throws IOException
125        {
126            body.println(arg0);
127        }
128    
129        public void println(float arg0) throws IOException
130        {
131            body.println(arg0);
132        }
133        
134        public void println(double arg0) throws IOException
135        {
136            body.println(arg0);
137        }
138    
139        public void println(char[] arg0) throws IOException
140        {
141            body.println(arg0);
142        }
143    
144        public void println(String arg0) throws IOException
145        {
146            body.println(arg0);
147        }
148    
149        public void println(Object arg0) throws IOException
150        {
151            body.println(arg0);
152        }
153    
154        public void clear() throws IOException
155        {
156            body.clear();
157        }
158    
159        public void clearBuffer() throws IOException
160        {
161            body.clearBuffer();
162        }
163    
164        public void close() throws IOException
165        {
166            body.close();
167        }
168    
169        public int getRemaining()
170        {
171            return body.getRemaining();
172        }
173    
174        public void write(char[] cbuf, int off, int len) throws IOException
175        {
176            body.write(cbuf, off, len);
177        }
178    }