001
014
015 package com.liferay.portal.kernel.servlet;
016
017 import com.liferay.portal.kernel.io.unsync.UnsyncStringWriter;
018 import com.liferay.portal.kernel.util.StringBundler;
019
020 import java.io.IOException;
021 import java.io.Reader;
022 import java.io.Writer;
023
024 import javax.servlet.jsp.JspWriter;
025 import javax.servlet.jsp.tagext.BodyContent;
026
027
030 public class BodyContentWrapper extends BodyContent {
031
032 public BodyContentWrapper(
033 BodyContent bodyContent, UnsyncStringWriter unsyncStringWriter) {
034
035 super(bodyContent.getEnclosingWriter());
036
037 _bodyContent = bodyContent;
038 _unsyncStringWriter = unsyncStringWriter;
039 }
040
041 @Override
042 public Writer append(char c) throws IOException {
043 return _bodyContent.append(c);
044 }
045
046 @Override
047 public Writer append(CharSequence charSequence) throws IOException {
048 return _bodyContent.append(charSequence);
049 }
050
051 @Override
052 public Writer append(CharSequence charSequence, int start, int end)
053 throws IOException {
054
055 return _bodyContent.append(charSequence, start, end);
056 }
057
058 @Override
059 public void clear() throws IOException {
060 _bodyContent.clear();
061 }
062
063 @Override
064 public void clearBody() {
065 _unsyncStringWriter.reset();
066 }
067
068 @Override
069 public void clearBuffer() {
070 _unsyncStringWriter.reset();
071 }
072
073 @Override
074 public void close() throws IOException {
075 _bodyContent.close();
076 }
077
078 @Override
079 public void flush() throws IOException {
080 _bodyContent.flush();
081 }
082
083 @Override
084 public int getBufferSize() {
085 return _bodyContent.getBufferSize();
086 }
087
088 @Override
089 public JspWriter getEnclosingWriter() {
090 return _bodyContent.getEnclosingWriter();
091 }
092
093 @Override
094 public Reader getReader() {
095 return _bodyContent.getReader();
096 }
097
098 @Override
099 public int getRemaining() {
100 return _bodyContent.getRemaining();
101 }
102
103 @Override
104 public String getString() {
105 return _unsyncStringWriter.toString();
106 }
107
108 public StringBundler getStringBundler() {
109 return _unsyncStringWriter.getStringBundler();
110 }
111
112 @Override
113 public boolean isAutoFlush() {
114 return _bodyContent.isAutoFlush();
115 }
116
117 @Override
118 public void newLine() throws IOException {
119 _bodyContent.newLine();
120 }
121
122 @Override
123 public void print(boolean b) throws IOException {
124 _bodyContent.print(b);
125 }
126
127 @Override
128 public void print(char c) throws IOException {
129 _bodyContent.print(c);
130 }
131
132 @Override
133 public void print(char[] chars) throws IOException {
134 _bodyContent.print(chars);
135 }
136
137 @Override
138 public void print(double d) throws IOException {
139 _bodyContent.print(d);
140 }
141
142 @Override
143 public void print(float f) throws IOException {
144 _bodyContent.print(f);
145 }
146
147 @Override
148 public void print(int i) throws IOException {
149 _bodyContent.print(i);
150 }
151
152 @Override
153 public void print(long l) throws IOException {
154 _bodyContent.print(l);
155 }
156
157 @Override
158 public void print(Object object) throws IOException {
159 _bodyContent.print(object);
160 }
161
162 @Override
163 public void print(String string) throws IOException {
164 _bodyContent.print(string);
165 }
166
167 @Override
168 public void println() throws IOException {
169 _bodyContent.println();
170 }
171
172 @Override
173 public void println(boolean b) throws IOException {
174 _bodyContent.println(b);
175 }
176
177 @Override
178 public void println(char c) throws IOException {
179 _bodyContent.println(c);
180 }
181
182 @Override
183 public void println(char[] chars) throws IOException {
184 _bodyContent.println(chars);
185 }
186
187 @Override
188 public void println(double d) throws IOException {
189 _bodyContent.println(d);
190 }
191
192 @Override
193 public void println(float f) throws IOException {
194 _bodyContent.println(f);
195 }
196
197 @Override
198 public void println(int i) throws IOException {
199 _bodyContent.println(i);
200 }
201
202 @Override
203 public void println(long l) throws IOException {
204 _bodyContent.println(l);
205 }
206
207 @Override
208 public void println(Object object) throws IOException {
209 _bodyContent.println(object);
210 }
211
212 @Override
213 public void println(String string) throws IOException {
214 _bodyContent.println(string);
215 }
216
217 @Override
218 public void write(char[] chars) throws IOException {
219 _bodyContent.write(chars);
220 }
221
222 @Override
223 public void write(char[] chars, int offset, int length) throws IOException {
224 _bodyContent.write(chars, offset, length);
225 }
226
227 @Override
228 public void write(int c) throws IOException {
229 _bodyContent.write(c);
230 }
231
232 @Override
233 public void write(String string) throws IOException {
234 _bodyContent.write(string);
235 }
236
237 @Override
238 public void write(String string, int offset, int length)
239 throws IOException {
240
241 _bodyContent.write(string, offset, length);
242 }
243
244 @Override
245 public void writeOut(Writer writer) throws IOException {
246 _bodyContent.writeOut(writer);
247 }
248
249 private BodyContent _bodyContent;
250 private UnsyncStringWriter _unsyncStringWriter;
251
252 }