KickJava   Java API By Example, From Geeks To Geeks.

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


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 import java.io.IOException JavaDoc;
10
11 import javax.servlet.jsp.JspWriter JavaDoc;
12
13 /**
14  * <p>
15  * This class is a mock object for the JspWriter.
16  * </p>
17  *
18  * @author Brian Pontarelli
19  * @since 2.0
20  * @version 2.0
21  */

22 public class MockJspWriter extends JspWriter JavaDoc {
23
24     private StringBuffer JavaDoc buf;
25
26
27     /**
28      * Constructor for MockJspWriter.
29      */

30     public MockJspWriter(int length, boolean autoFlush) {
31         super(length, autoFlush);
32         buf = new StringBuffer JavaDoc();
33     }
34
35
36     public void print(String JavaDoc a) {
37         buf.append(a);
38     }
39
40     public void print(boolean a) {
41         buf.append(a);
42     }
43
44     public void print(float a) {
45         buf.append(a);
46     }
47
48     public void print(char a) {
49         buf.append(a);
50     }
51
52     public void print(int a) {
53         buf.append(a);
54     }
55
56     public void println(String JavaDoc a) {
57         buf.append(a);
58     }
59
60     public void print(double a) {
61         buf.append(a);
62     }
63
64     public void print(long a) {
65         buf.append(a);
66     }
67
68     public void print(char[] a) {
69         buf.append(a);
70     }
71
72     public void print(Object JavaDoc a) {
73         buf.append(a);
74     }
75
76     public void println() {
77         buf.append("\n");
78     }
79
80     public void println(boolean a) {
81         buf.append(a).append("\n");
82     }
83
84     public void println(char a) {
85         buf.append(a).append("\n");
86     }
87
88     public void println(int a) {
89         buf.append(a).append("\n");
90     }
91
92     public void println(float a) {
93         buf.append(a).append("\n");
94     }
95
96     public void println(double a) {
97         buf.append(a).append("\n");
98     }
99
100     public void println(long a) {
101         buf.append(a).append("\n");
102     }
103
104     public void println(char[] a) {
105         buf.append(a).append("\n");
106     }
107
108     public void println(Object JavaDoc a) {
109         buf.append(a).append("\n");
110     }
111
112     public void write(int a) {
113         buf.append(a + "\n");
114     }
115
116     public void write(byte[] a) {
117         buf.append(new String JavaDoc(a));
118     }
119
120     public void write(byte[] a, int b, int c) {
121         buf.append(new String JavaDoc(a, b, c));
122     }
123
124     public void write(char[] cbuf, int off, int len) {
125         buf.append(new String JavaDoc(cbuf, off, len));
126     }
127
128     public void newLine() throws IOException JavaDoc {
129         buf.append("\n");
130     }
131
132     public int getRemaining() {
133         return getBufferSize() - buf.length();
134     }
135
136     public void clear() {
137         buf.delete(0, buf.length());
138     }
139
140     public void clearBuffer() {
141         buf.delete(0, buf.length());
142     }
143
144     public void flush() {
145         // NO OP
146
}
147
148     public void close() {
149         // NO OP
150
}
151
152     public String JavaDoc getText() {
153         return buf.toString();
154     }
155 }
Popular Tags