KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > junit > internal > http > MockBodyContent


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.junit.internal.http;
8
9
10 import java.io.IOException JavaDoc;
11 import java.io.Reader JavaDoc;
12 import java.io.StringReader JavaDoc;
13 import java.io.Writer JavaDoc;
14
15 import javax.servlet.jsp.JspWriter JavaDoc;
16 import javax.servlet.jsp.tagext.BodyContent JavaDoc;
17
18
19 /**
20  * <p>
21  * This class is a mock version of the BodyContent class
22  * </p>
23  *
24  * @author Brian Pontarelli
25  * @since 2.0
26  * @version 2.0
27  */

28 public class MockBodyContent extends BodyContent JavaDoc {
29
30     private String JavaDoc bodyContent;
31
32
33     /**
34      * Constructor for MockBodyContent.
35      *
36      * @param writer The JspWriter
37      */

38     public MockBodyContent(String JavaDoc bodyContent, JspWriter JavaDoc writer) {
39         super(writer);
40         this.bodyContent = bodyContent;
41     }
42
43
44     /**
45      * @see javax.servlet.jsp.tagext.BodyContent#getReader()
46      */

47     public Reader JavaDoc getReader() {
48         if (bodyContent == null) {
49             return new StringReader JavaDoc("");
50         }
51
52         return new StringReader JavaDoc(bodyContent);
53     }
54
55     /**
56      * @see javax.servlet.jsp.tagext.BodyContent#getString()
57      */

58     public String JavaDoc getString() {
59         return bodyContent;
60     }
61
62     /**
63      * @see javax.servlet.jsp.tagext.BodyContent#writeOut(java.io.Writer)
64      */

65     public void writeOut(Writer JavaDoc writer) throws IOException JavaDoc {
66         if (bodyContent != null) {
67             writer.write(bodyContent);
68         }
69     }
70
71     /**
72      * @see javax.servlet.jsp.JspWriter#newLine()
73      */

74     public void newLine() throws IOException JavaDoc {
75         getEnclosingWriter().write("\n");
76     }
77
78     /**
79      * @see javax.servlet.jsp.JspWriter#print(boolean)
80      */

81     public void print(boolean b) throws IOException JavaDoc {
82         getEnclosingWriter().write("" + b);
83     }
84
85     /**
86      * @see javax.servlet.jsp.JspWriter#print(char)
87      */

88     public void print(char c) throws IOException JavaDoc {
89         getEnclosingWriter().write("" + c);
90     }
91
92     /**
93      * @see javax.servlet.jsp.JspWriter#print(int)
94      */

95     public void print(int i) throws IOException JavaDoc {
96         getEnclosingWriter().write("" + i);
97     }
98
99     /**
100      * @see javax.servlet.jsp.JspWriter#print(long)
101      */

102     public void print(long l) throws IOException JavaDoc {
103         getEnclosingWriter().write("" + l);
104     }
105
106     /**
107      * @see javax.servlet.jsp.JspWriter#print(float)
108      */

109     public void print(float f) throws IOException JavaDoc {
110         getEnclosingWriter().write("" + f);
111     }
112
113     /**
114      * @see javax.servlet.jsp.JspWriter#print(double)
115      */

116     public void print(double d) throws IOException JavaDoc {
117         getEnclosingWriter().write("" + d);
118     }
119
120     /**
121      * @see javax.servlet.jsp.JspWriter#print(char)
122      */

123     public void print(char[] str) throws IOException JavaDoc {
124         getEnclosingWriter().write(str);
125     }
126
127     /**
128      * @see javax.servlet.jsp.JspWriter#print(java.lang.String)
129      */

130     public void print(String JavaDoc str) throws IOException JavaDoc {
131         getEnclosingWriter().write(str);
132     }
133
134     /**
135      * @see javax.servlet.jsp.JspWriter#print(java.lang.Object)
136      */

137     public void print(Object JavaDoc obj) throws IOException JavaDoc {
138         getEnclosingWriter().write(obj.toString());
139     }
140
141     /**
142      * @see javax.servlet.jsp.JspWriter#println()
143      */

144     public void println() throws IOException JavaDoc {
145         getEnclosingWriter().write("\n");
146     }
147
148     /**
149      * @see javax.servlet.jsp.JspWriter#println(boolean)
150      */

151     public void println(boolean b) throws IOException JavaDoc {
152         getEnclosingWriter().write("" + b);
153         getEnclosingWriter().write("\n");
154     }
155
156     /**
157      * @see javax.servlet.jsp.JspWriter#println(char)
158      */

159     public void println(char c) throws IOException JavaDoc {
160         getEnclosingWriter().write("" + c);
161         getEnclosingWriter().write("\n");
162     }
163
164     /**
165      * @see javax.servlet.jsp.JspWriter#println(int)
166      */

167     public void println(int i) throws IOException JavaDoc {
168         getEnclosingWriter().write("" + i);
169         getEnclosingWriter().write("\n");
170     }
171
172     /**
173      * @see javax.servlet.jsp.JspWriter#println(long)
174      */

175     public void println(long l) throws IOException JavaDoc {
176         getEnclosingWriter().write("" + l);
177         getEnclosingWriter().write("\n");
178     }
179
180     /**
181      * @see javax.servlet.jsp.JspWriter#println(float)
182      */

183     public void println(float f) throws IOException JavaDoc {
184         getEnclosingWriter().write("" + f);
185         getEnclosingWriter().write("\n");
186     }
187
188     /**
189      * @see javax.servlet.jsp.JspWriter#println(double)
190      */

191     public void println(double d) throws IOException JavaDoc {
192         getEnclosingWriter().write("" + d);
193         getEnclosingWriter().write("\n");
194     }
195
196     /**
197      * @see javax.servlet.jsp.JspWriter#println(char)
198      */

199     public void println(char[] str) throws IOException JavaDoc {
200         getEnclosingWriter().write(str);
201         getEnclosingWriter().write("\n");
202     }
203
204     /**
205      * @see javax.servlet.jsp.JspWriter#println(java.lang.String)
206      */

207     public void println(String JavaDoc str) throws IOException JavaDoc {
208         getEnclosingWriter().write(str);
209         getEnclosingWriter().write("\n");
210     }
211
212     /**
213      * @see javax.servlet.jsp.JspWriter#println(java.lang.Object)
214      */

215     public void println(Object JavaDoc obj) throws IOException JavaDoc {
216         getEnclosingWriter().write(obj.toString());
217         getEnclosingWriter().write("\n");
218     }
219
220     /**
221      * @see javax.servlet.jsp.JspWriter#clear()
222      */

223     public void clear() throws IOException JavaDoc {
224     }
225
226     /**
227      * @see javax.servlet.jsp.JspWriter#clearBuffer()
228      */

229     public void clearBuffer() throws IOException JavaDoc {
230     }
231
232     /**
233      * @see java.io.Writer#close()
234      */

235     public void close() throws IOException JavaDoc {
236     }
237
238     /**
239      * @see javax.servlet.jsp.JspWriter#getRemaining()
240      */

241     public int getRemaining() {
242         return 0;
243     }
244
245     /**
246      * @see java.io.Writer#write(char[], int, int)
247      */

248     public void write(char[] cbuf, int off, int len) throws IOException JavaDoc {
249         getEnclosingWriter().write(cbuf, off, len);
250     }
251 }
Popular Tags