KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jsp > WebWorkMockJspWriter


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.views.jsp;
6
7 import com.mockobjects.servlet.MockJspWriter;
8
9 import javax.servlet.jsp.JspWriter JavaDoc;
10 import java.io.IOException JavaDoc;
11 import java.io.StringWriter JavaDoc;
12
13
14 /**
15  * Unforunately, the MockJspWriter throws a NotImplementedException when any of the Writer methods are invoked and
16  * as you might guess, Velocity uses the Writer methods. I'velocityEngine subclassed the MockJspWriter for the time being so
17  * that we can do testing on the results until MockJspWriter gets fully implemented.
18  * <p/>
19  * todo replace this once MockJspWriter implements Writer correctly (i.e. doesn't throw NotImplementException)
20  */

21 public class WebWorkMockJspWriter extends JspWriter {
22     StringWriter JavaDoc writer;
23
24     public WebWorkMockJspWriter(StringWriter JavaDoc writer) {
25         super(1024, true);
26         this.writer = writer;
27     }
28
29     public void newLine() throws IOException JavaDoc {
30         writer.write("\n");
31     }
32
33     public void print(boolean b) throws IOException JavaDoc {
34         writer.write(String.valueOf(b));
35     }
36
37     public void print(char c) throws IOException JavaDoc {
38         writer.write(String.valueOf(c));
39     }
40
41     public void print(int i) throws IOException JavaDoc {
42         writer.write(i);
43     }
44
45     public void print(long l) throws IOException JavaDoc {
46         writer.write(String.valueOf(l));
47     }
48
49     public void print(float v) throws IOException JavaDoc {
50         writer.write(String.valueOf(v));
51     }
52
53     public void print(double v) throws IOException JavaDoc {
54         writer.write(String.valueOf(v));
55     }
56
57     public void print(char[] chars) throws IOException JavaDoc {
58         writer.write(chars);
59     }
60
61     public void print(String JavaDoc s) throws IOException JavaDoc {
62         writer.write(s);
63     }
64
65     public void print(Object JavaDoc o) throws IOException JavaDoc {
66         writer.write(o.toString());
67     }
68
69     public void println() throws IOException JavaDoc {
70         writer.write("\n");
71     }
72
73     public void println(boolean b) throws IOException JavaDoc {
74         print(b);
75         println();
76     }
77
78     public void println(char c) throws IOException JavaDoc {
79         print(c);
80         println();
81     }
82
83     public void println(int i) throws IOException JavaDoc {
84         print(i);
85         println();
86     }
87
88     public void println(long l) throws IOException JavaDoc {
89         print(l);
90         println();
91     }
92
93     public void println(float v) throws IOException JavaDoc {
94         print(v);
95         println();
96     }
97
98     public void println(double v) throws IOException JavaDoc {
99         print(v);
100         println();
101     }
102
103     public void println(char[] chars) throws IOException JavaDoc {
104         print(chars);
105         println();
106     }
107
108     public void println(String JavaDoc s) throws IOException JavaDoc {
109         print(s);
110         println();
111     }
112
113     public void println(Object JavaDoc o) throws IOException JavaDoc {
114         print(o);
115         println();
116     }
117
118     public void clear() throws IOException JavaDoc {
119     }
120
121     public void clearBuffer() throws IOException JavaDoc {
122     }
123
124     public void close() throws IOException JavaDoc {
125         writer.close();
126     }
127
128     public int getRemaining() {
129         return 0;
130     }
131
132     public void write(char cbuf[], int off, int len) throws IOException JavaDoc {
133         writer.write(cbuf, off, len);
134     }
135
136     public void write(String JavaDoc str) throws IOException JavaDoc {
137         writer.write(str);
138     }
139
140     public void write(int c) throws IOException JavaDoc {
141         writer.write(c);
142     }
143
144     public void write(char[] cbuf) throws IOException JavaDoc {
145         writer.write(cbuf);
146     }
147
148     public void write(String JavaDoc str, int off, int len) throws IOException JavaDoc {
149         writer.write(str, off, len);
150     }
151
152     public void flush() {
153         writer.flush();
154     }
155 }
156
Popular Tags