home *** CD-ROM | disk | FTP | other *** search
/ PC Professionell 2004 December / PCpro_2004_12.ISO / files / webserver / xampp / xampp-tomcat-addon-1.4.9-installer.exe / servlet-api.jar / javax / servlet / http / NoBodyResponse.class (.txt) < prev   
Encoding:
Java Class File  |  2004-08-28  |  4.9 KB  |  165 lines

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