1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package com.macvu.tiles.capture;
20
21 import org.apache.commons.logging.Log;
22 import org.apache.commons.logging.LogFactory;
23
24 import javax.servlet.ServletOutputStream;
25 import java.io.IOException;
26
27 public class CacheServletOutputStream extends ServletOutputStream {
28 protected static Log log = LogFactory.getLog(CacheServletOutputStream.class);
29
30 ServletOutputStream delegate;
31 CacheContent cacheContent;
32
33 public CacheServletOutputStream(ServletOutputStream out, CacheContent cacheContent) {
34 if (log.isDebugEnabled()) {
35 log.debug("CacheServletOutputStream: Enter contructor.");
36 }
37 delegate = out;
38 this.cacheContent = cacheContent;
39 }
40
41 public void write(int b) throws IOException {
42 if (log.isDebugEnabled()) {
43 log.debug("CacheServletOutputStream: write(int b).");
44 }
45 delegate.write(b);
46 cacheContent.getOutputStream().write(b);
47 }
48
49 public void write(byte b[]) throws IOException {
50 if (log.isDebugEnabled()) {
51 log.debug("CacheServletOutputStream: write(byte b[]).");
52 }
53 delegate.write(b);
54 cacheContent.getOutputStream().write(b);
55 }
56
57 public void write(byte buf[], int offset, int len) throws IOException {
58 if (log.isDebugEnabled()) {
59 log.debug("CacheServletOutputStream: Enter write (byte buf[], int offset, int len ).");
60 }
61 delegate.write(buf, offset, len);
62 cacheContent.getOutputStream().write(buf, offset, len);
63 }
64
65 public void print(boolean b) throws IOException {
66 if (log.isDebugEnabled()) {
67 log.debug("CacheServletOutputStream: Enter contructor.");
68 }
69 delegate.print(b);
70 String toString = String.valueOf(b);
71 cacheContent.getOutputStream().write(toString.getBytes());
72 }
73
74 public void print(char c) throws IOException {
75 if (log.isDebugEnabled()) {
76 log.debug("CacheServletOutputStream: Enter contructor.");
77 }
78 delegate.print(c);
79 cacheContent.getOutputStream().write(c);
80 }
81
82 public void print(double v) throws IOException {
83 if (log.isDebugEnabled()) {
84 log.debug("CacheServletOutputStream: Enter contructor.");
85 }
86 delegate.print(v);
87 cacheContent.getOutputStream().write(String.valueOf(v).getBytes());
88 }
89
90 public void print(float v) throws IOException {
91 if (log.isDebugEnabled()) {
92 log.debug("CacheServletOutputStream: Enter contructor.");
93 }
94 delegate.print(v);
95 cacheContent.getOutputStream().write(String.valueOf(v).getBytes());
96 }
97
98 public void print(int i) throws IOException {
99 if (log.isDebugEnabled()) {
100 log.debug("CacheServletOutputStream: Enter contructor.");
101 }
102 delegate.print(i);
103 cacheContent.getOutputStream().write(String.valueOf(i).getBytes());
104 }
105
106 public void print(long l) throws IOException {
107 if (log.isDebugEnabled()) {
108 log.debug("CacheServletOutputStream: Enter contructor.");
109 }
110 delegate.print(l);
111 cacheContent.getOutputStream().write(String.valueOf(l).getBytes());
112 }
113
114 public void print(String s) throws IOException {
115 if (log.isDebugEnabled()) {
116 log.debug("CacheServletOutputStream: Enter contructor.");
117 }
118 delegate.print(s);
119 cacheContent.getOutputStream().write(String.valueOf(s).getBytes());
120 }
121
122 public void println() throws IOException {
123 if (log.isDebugEnabled()) {
124 log.debug("CacheServletOutputStream: Enter contructor.");
125 }
126 delegate.println();
127 }
128
129 public void println(boolean b) throws IOException {
130 if (log.isDebugEnabled()) {
131 log.debug("CacheServletOutputStream: Enter contructor.");
132 }
133 delegate.println(b);
134 cacheContent.getOutputStream().write(String.valueOf(b).getBytes());
135 }
136
137 public void println(char c) throws IOException {
138 if (log.isDebugEnabled()) {
139 log.debug("CacheServletOutputStream: Enter contructor.");
140 }
141 delegate.println(c);
142 cacheContent.getOutputStream().write(String.valueOf(c).getBytes());
143 }
144
145 public void println(double v) throws IOException {
146 if (log.isDebugEnabled()) {
147 log.debug("CacheServletOutputStream: Enter contructor.");
148 }
149 delegate.println(v);
150 cacheContent.getOutputStream().write(String.valueOf(v).getBytes());
151 }
152
153 public void println(float v) throws IOException {
154 if (log.isDebugEnabled()) {
155 log.debug("CacheServletOutputStream: Enter contructor.");
156 }
157 delegate.println(v);
158 cacheContent.getOutputStream().write(String.valueOf(v).getBytes());
159 }
160
161 public void println(int i) throws IOException {
162 if (log.isDebugEnabled()) {
163 log.debug("CacheServletOutputStream: Enter contructor.");
164 }
165 delegate.println(i);
166 cacheContent.getOutputStream().write(String.valueOf(i).getBytes());
167 }
168
169 public void println(long l) throws IOException {
170 if (log.isDebugEnabled()) {
171 log.debug("CacheServletOutputStream: Enter contructor.");
172 }
173 delegate.println(l);
174 cacheContent.getOutputStream().write(String.valueOf(l).getBytes());
175 }
176
177 public void println(String s) throws IOException {
178 if (log.isDebugEnabled()) {
179 log.debug("CacheServletOutputStream: Enter contructor.");
180 }
181 delegate.println(s);
182 cacheContent.getOutputStream().write(String.valueOf(s).getBytes());
183 }
184
185 public void close() throws IOException {
186 delegate.close();
187 }
188
189 public void flush() throws IOException {
190 delegate.flush();
191 }
192 }