001: /*
002: * Copyright (C) 2006 Methodhead Software LLC. All rights reserved.
003: *
004: * This file is part of TransferCM.
005: *
006: * TransferCM is free software; you can redistribute it and/or modify it under the
007: * terms of the GNU General Public License as published by the Free Software
008: * Foundation; either version 2 of the License, or (at your option) any later
009: * version.
010: *
011: * TransferCM is distributed in the hope that it will be useful, but WITHOUT ANY
012: * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
013: * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
014: * details.
015: *
016: * You should have received a copy of the GNU General Public License along with
017: * TransferCM; if not, write to the Free Software Foundation, Inc., 51 Franklin St,
018: * Fifth Floor, Boston, MA 02110-1301 USA
019: */
020:
021: package com.methodhead.shim;
022:
023: import javax.servlet.http.HttpServletResponse;
024: import javax.servlet.ServletResponse;
025: import javax.servlet.ServletOutputStream;
026: import java.util.Locale;
027: import java.io.PrintWriter;
028: import javax.servlet.http.Cookie;
029:
030: /**
031: * A servlet response that discards any output. All methods of this class are
032: * empty implementations.
033: */
034: public class NullHttpServletResponse implements HttpServletResponse {
035:
036: // constructors /////////////////////////////////////////////////////////////
037:
038: public NullHttpServletResponse() {
039: out_ = new NullServletOutputStream();
040: }
041:
042: // constants ////////////////////////////////////////////////////////////////
043:
044: // classes //////////////////////////////////////////////////////////////////
045:
046: private static class NullServletOutputStream extends
047: ServletOutputStream {
048:
049: public void write(int b) {
050: // do nothing
051: }
052: }
053:
054: // methods //////////////////////////////////////////////////////////////////
055:
056: public void flushBuffer() {
057: }
058:
059: public int getBufferSize() {
060: return 0;
061: }
062:
063: public String getCharacterEncoding() {
064: return "";
065: }
066:
067: public Locale getLocale() {
068: return Locale.getDefault();
069: }
070:
071: public ServletOutputStream getOutputStream() {
072: return out_;
073: }
074:
075: public PrintWriter getWriter() {
076: return new PrintWriter(out_);
077: }
078:
079: public boolean isCommitted() {
080: return false;
081: }
082:
083: public void reset() {
084: }
085:
086: public void resetBuffer() {
087: }
088:
089: public void setBufferSize(int size) {
090: }
091:
092: public void setContentLength(int len) {
093: }
094:
095: public void setContentType(String type) {
096: }
097:
098: public void setLocale(Locale loc) {
099: }
100:
101: public void setResponse(ServletResponse response) {
102: }
103:
104: public void addCookie(Cookie cookie) {
105: }
106:
107: public void addDateHeader(String name, long date) {
108: }
109:
110: public void addHeader(String name, String value) {
111: }
112:
113: public void addIntHeader(String name, int value) {
114: }
115:
116: public boolean containsHeader(String name) {
117: return false;
118: }
119:
120: public String encodeRedirectUrl(String url) {
121: return url;
122: }
123:
124: public String encodeRedirectURL(String url) {
125: return url;
126: }
127:
128: public String encodeUrl(String url) {
129: return url;
130: }
131:
132: public String encodeURL(String url) {
133: return url;
134: }
135:
136: public void sendError(int sc) {
137: }
138:
139: public void sendError(int sc, String msg) {
140: }
141:
142: public void sendRedirect(String location) {
143: }
144:
145: public void setDateHeader(String name, long date) {
146: }
147:
148: public void setHeader(String name, String value) {
149: }
150:
151: public void setIntHeader(String name, int value) {
152: }
153:
154: public void setStatus(int sc) {
155: }
156:
157: public void setStatus(int sc, String sm) {
158: }
159:
160: // properties ///////////////////////////////////////////////////////////////
161:
162: ServletOutputStream out_ = null;
163:
164: // attributes ///////////////////////////////////////////////////////////////
165: }
|