KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > methodhead > shim > NullHttpServletResponse


1 /*
2  * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
3  *
4  * This file is part of TransferCM.
5  *
6  * TransferCM is free software; you can redistribute it and/or modify it under the
7  * terms of the GNU General Public License as published by the Free Software
8  * Foundation; either version 2 of the License, or (at your option) any later
9  * version.
10  *
11  * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
12  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License along with
17  * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
18  * Fifth Floor, Boston, MA 02110-1301 USA
19  */

20
21 package com.methodhead.shim;
22
23 import javax.servlet.http.HttpServletResponse JavaDoc;
24 import javax.servlet.ServletResponse JavaDoc;
25 import javax.servlet.ServletOutputStream JavaDoc;
26 import java.util.Locale JavaDoc;
27 import java.io.PrintWriter JavaDoc;
28 import javax.servlet.http.Cookie JavaDoc;
29
30 /**
31  * A servlet response that discards any output. All methods of this class are
32  * empty implementations.
33  */

34 public class NullHttpServletResponse
35 implements
36   HttpServletResponse JavaDoc {
37
38   // constructors /////////////////////////////////////////////////////////////
39

40   public NullHttpServletResponse() {
41     out_ = new NullServletOutputStream();
42   }
43
44   // constants ////////////////////////////////////////////////////////////////
45

46   // classes //////////////////////////////////////////////////////////////////
47

48   private static class NullServletOutputStream
49   extends
50     ServletOutputStream JavaDoc {
51
52     public void write( int b ) {
53       // do nothing
54
}
55   }
56
57   // methods //////////////////////////////////////////////////////////////////
58

59   public void flushBuffer() {
60   }
61
62   public int getBufferSize() {
63     return 0;
64   }
65
66   public String JavaDoc getCharacterEncoding() {
67     return "";
68   }
69
70   public Locale JavaDoc getLocale() {
71     return Locale.getDefault();
72   }
73
74   public ServletOutputStream JavaDoc getOutputStream() {
75     return out_;
76   }
77
78   public PrintWriter JavaDoc getWriter() {
79     return new PrintWriter JavaDoc( out_ );
80   }
81
82   public boolean isCommitted() {
83     return false;
84   }
85
86   public void reset() {
87   }
88
89   public void resetBuffer() {
90   }
91
92   public void setBufferSize( int size ) {
93   }
94
95   public void setContentLength( int len ) {
96   }
97
98   public void setContentType( String JavaDoc type ) {
99   }
100
101   public void setLocale( Locale JavaDoc loc ) {
102   }
103
104   public void setResponse( ServletResponse JavaDoc response ) {
105   }
106
107   public void addCookie( Cookie JavaDoc cookie ) {
108   }
109
110   public void addDateHeader( String JavaDoc name, long date ) {
111   }
112
113   public void addHeader( String JavaDoc name, String JavaDoc value ) {
114   }
115
116   public void addIntHeader( String JavaDoc name, int value ) {
117   }
118
119   public boolean containsHeader( String JavaDoc name ) {
120     return false;
121   }
122
123   public String JavaDoc encodeRedirectUrl( String JavaDoc url ) {
124     return url;
125   }
126
127   public String JavaDoc encodeRedirectURL( String JavaDoc url ) {
128     return url;
129   }
130
131   public String JavaDoc encodeUrl( String JavaDoc url ) {
132     return url;
133   }
134
135   public String JavaDoc encodeURL( String JavaDoc url ) {
136     return url;
137   }
138
139   public void sendError( int sc ) {
140   }
141
142   public void sendError( int sc, String JavaDoc msg ) {
143   }
144
145   public void sendRedirect( String JavaDoc location ) {
146   }
147
148   public void setDateHeader( String JavaDoc name, long date ) {
149   }
150
151   public void setHeader( String JavaDoc name, String JavaDoc value ) {
152   }
153
154   public void setIntHeader( String JavaDoc name, int value ) {
155   }
156
157   public void setStatus( int sc ) {
158   }
159
160   public void setStatus( int sc, String JavaDoc sm ) {
161   }
162
163   // properties ///////////////////////////////////////////////////////////////
164

165   ServletOutputStream JavaDoc out_ = null;
166
167   // attributes ///////////////////////////////////////////////////////////////
168
}
169
Popular Tags