1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.extremecomponents.table.filter;
17
18 import java.io.ByteArrayOutputStream;
19 import java.io.PrintWriter;
20
21 import javax.servlet.ServletOutputStream;
22 import javax.servlet.http.HttpServletResponse;
23 import javax.servlet.http.HttpServletResponseWrapper;
24
25
26 /***
27 * @author Jeff Johnston
28 */
29 public class GenericResponseWrapper extends HttpServletResponseWrapper
30 {
31 private ByteArrayOutputStream output;
32 private int contentLength;
33 private String contentType;
34
35 public GenericResponseWrapper(HttpServletResponse response)
36 {
37 super(response);
38 output = new ByteArrayOutputStream();
39 }
40
41 public byte[] getData()
42 {
43 return output.toByteArray();
44 }
45
46 public ServletOutputStream getOutputStream()
47 {
48 return new FilterServletOutputStream(output);
49 }
50
51 public PrintWriter getWriter()
52 {
53 return new PrintWriter(getOutputStream(), true);
54 }
55
56 public void setContentLength(int length)
57 {
58 this.contentLength = length;
59 super.setContentLength(length);
60 }
61
62 public int getContentLength()
63 {
64 return contentLength;
65 }
66
67 public void setContentType(String type)
68 {
69 this.contentType = type;
70 super.setContentType(type);
71 }
72
73 public String getContentType()
74 {
75 return contentType;
76 }
77 }