View Javadoc

1   package net.sourceforge.blogentis.slide;
2   
3   //-----------------------------------------------------------------------
4   //Blogentis - a blog publishing platform.
5   //Copyright (C) 2004 Tassos Bassoukos <abassouk@gmail.com>
6   //
7   //This library is free software; you can redistribute it and/or
8   //modify it under the terms of the GNU Lesser General Public
9   //License as published by the Free Software Foundation; either
10  //version 2.1 of the License, or (at your option) any later version.
11  //
12  //This library is distributed in the hope that it will be useful,
13  //but WITHOUT ANY WARRANTY; without even the implied warranty of
14  //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  //Lesser General Public License for more details.
16  //
17  //You should have received a copy of the GNU Lesser General Public
18  //License along with this library; if not, write to the Free Software
19  //Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20  //-----------------------------------------------------------------------
21  //
22  //$Id: MemoryHttpServletResponse.java,v 1.1 2004/10/22 17:34:16 tassos Exp $
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 }