1 package net.sourceforge.blogentis.slide;
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25 import java.io.IOException;
26 import java.io.PrintWriter;
27 import java.util.Locale;
28
29 import javax.servlet.ServletOutputStream;
30 import javax.servlet.http.Cookie;
31 import javax.servlet.http.HttpServletResponse;
32
33 /***
34 *
35 * @author abas
36 */
37 public class MemoryHttpServletResponse
38 implements HttpServletResponse {
39 static class DummyOutputStream
40 extends ServletOutputStream {
41 public void close() {}
42
43 public void flush() {}
44
45 public void write(byte[] b, int off, int len) {}
46
47 public void write(byte[] b) {}
48
49 public void write(int b)
50 throws IOException {}
51 }
52
53 private ServletOutputStream outputStream = new DummyOutputStream();
54 private int statusCode = 0;
55 private String statusMessage = null;
56
57 public void addCookie(Cookie cookie) {}
58
59 public boolean containsHeader(String name) {
60 return false;
61 }
62
63 public String encodeURL(String url) {
64 return url;
65 }
66
67 public String encodeRedirectURL(String url) {
68 return url;
69 }
70
71 public String encodeUrl(String url) {
72 return url;
73 }
74
75 public String encodeRedirectUrl(String url) {
76 return url;
77 }
78
79 public void sendError(int sc, String msg)
80 throws IOException {
81 this.statusCode = sc;
82 this.statusMessage = msg;
83 }
84
85 public void sendError(int sc)
86 throws IOException {
87 this.statusCode = sc;
88 }
89
90 public void sendRedirect(String location)
91 throws IOException {}
92
93 public void setDateHeader(String name, long date) {}
94
95 public void addDateHeader(String name, long date) {}
96
97 public void setHeader(String name, String value) {}
98
99 public void addHeader(String name, String value) {}
100
101 public void setIntHeader(String name, int value) {}
102
103 public void addIntHeader(String name, int value) {}
104
105 public void setStatus(int sc) {
106 this.statusCode = sc;
107 }
108
109 public void setStatus(int sc, String sm) {
110 this.statusCode = sc;
111 this.statusMessage = sm;
112 }
113
114 public String getCharacterEncoding() {
115 return null;
116 }
117
118 public ServletOutputStream getOutputStream()
119 throws IOException {
120 return this.outputStream;
121 }
122
123 public PrintWriter getWriter()
124 throws IOException {
125 return new PrintWriter(outputStream);
126 }
127
128 public void setContentLength(int len) {}
129
130 public void setContentType(String type) {}
131
132 public void setBufferSize(int size) {}
133
134 public int getBufferSize() {
135 return 0;
136 }
137
138 public void flushBuffer()
139 throws IOException {}
140
141 public void resetBuffer() {}
142
143 public boolean isCommitted() {
144 return false;
145 }
146
147 public void reset() {}
148
149 public void setLocale(Locale loc) {}
150
151 public Locale getLocale() {
152 return null;
153 }
154
155 public int getStatusCode() {
156 return statusCode;
157 }
158
159 public String getStatusMessage() {
160 return statusMessage;
161 }
162
163 public String getContentType() {
164 return null;
165 }
166
167 public void setCharacterEncoding(String arg0) {}
168 }