1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.portal.kernel.servlet;
16  
17  import com.liferay.portal.kernel.io.unsync.UnsyncStringWriter;
18  import com.liferay.portal.kernel.util.StringBundler;
19  
20  import java.io.IOException;
21  import java.io.Reader;
22  import java.io.Writer;
23  
24  import javax.servlet.jsp.JspWriter;
25  import javax.servlet.jsp.tagext.BodyContent;
26  
27  /**
28   * <a href="BodyContentWrapper.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Shuyang Zhou
31   */
32  public class BodyContentWrapper extends BodyContent {
33  
34      public BodyContentWrapper(
35          BodyContent bodyContent, UnsyncStringWriter unsyncStringWriter) {
36  
37          super(bodyContent.getEnclosingWriter());
38  
39          _bodyContent = bodyContent;
40          _unsyncStringWriter = unsyncStringWriter;
41      }
42  
43      public Writer append(char c) throws IOException {
44          return _bodyContent.append(c);
45      }
46  
47      public Writer append(CharSequence charSequence) throws IOException {
48          return _bodyContent.append(charSequence);
49      }
50  
51      public Writer append(CharSequence charSequence, int start, int end)
52          throws IOException {
53  
54          return _bodyContent.append(charSequence, start, end);
55      }
56  
57      public void clear() throws IOException {
58          _bodyContent.clear();
59      }
60  
61      public void clearBody() {
62          _unsyncStringWriter.reset();
63      }
64  
65      public void clearBuffer() {
66          _unsyncStringWriter.reset();
67      }
68  
69      public void close() throws IOException {
70          _bodyContent.close();
71      }
72  
73      public void flush() throws IOException {
74          _bodyContent.flush();
75      }
76  
77      public int getBufferSize() {
78          return _bodyContent.getBufferSize();
79      }
80  
81      public JspWriter getEnclosingWriter() {
82          return _bodyContent.getEnclosingWriter();
83      }
84  
85      public Reader getReader() {
86          return _bodyContent.getReader();
87      }
88  
89      public int getRemaining() {
90          return _bodyContent.getRemaining();
91      }
92  
93      public String getString() {
94          return _unsyncStringWriter.toString();
95      }
96  
97      public StringBundler getStringBundler() {
98          return _unsyncStringWriter.getStringBundler();
99      }
100 
101     public boolean isAutoFlush() {
102         return _bodyContent.isAutoFlush();
103     }
104 
105     public void newLine() throws IOException {
106         _bodyContent.newLine();
107     }
108 
109     public void print(boolean b) throws IOException {
110         _bodyContent.print(b);
111     }
112 
113     public void print(char c) throws IOException {
114         _bodyContent.print(c);
115     }
116 
117     public void print(char[] chars) throws IOException {
118         _bodyContent.print(chars);
119     }
120 
121     public void print(double d) throws IOException {
122         _bodyContent.print(d);
123     }
124 
125     public void print(float f) throws IOException {
126         _bodyContent.print(f);
127     }
128 
129     public void print(int i) throws IOException {
130         _bodyContent.print(i);
131     }
132 
133     public void print(long l) throws IOException {
134         _bodyContent.print(l);
135     }
136 
137     public void print(Object object) throws IOException {
138         _bodyContent.print(object);
139     }
140 
141     public void print(String string) throws IOException {
142         _bodyContent.print(string);
143     }
144 
145     public void println() throws IOException {
146         _bodyContent.println();
147     }
148 
149     public void println(boolean b) throws IOException {
150         _bodyContent.println(b);
151     }
152 
153     public void println(char c) throws IOException {
154         _bodyContent.println(c);
155     }
156 
157     public void println(char[] charArray) throws IOException {
158         _bodyContent.println(charArray);
159     }
160 
161     public void println(double d) throws IOException {
162         _bodyContent.println(d);
163     }
164 
165     public void println(float f) throws IOException {
166         _bodyContent.println(f);
167     }
168 
169     public void println(int i) throws IOException {
170         _bodyContent.println(i);
171     }
172 
173     public void println(long l) throws IOException {
174         _bodyContent.println(l);
175     }
176 
177     public void println(Object object) throws IOException {
178         _bodyContent.println(object);
179     }
180 
181     public void println(String string) throws IOException {
182         _bodyContent.println(string);
183     }
184 
185     public void write(char[] charArray) throws IOException {
186         _bodyContent.write(charArray);
187     }
188 
189     public void write(char[] charArray, int offset, int length)
190         throws IOException {
191 
192         _bodyContent.write(charArray, offset, length);
193     }
194 
195     public void write(int c) throws IOException {
196         _bodyContent.write(c);
197     }
198 
199     public void write(String string) throws IOException {
200         _bodyContent.write(string);
201     }
202 
203     public void write(String string, int offset, int length)
204         throws IOException {
205 
206         _bodyContent.write(string, offset, length);
207     }
208 
209     public void writeOut(Writer writer) throws IOException {
210         _bodyContent.writeOut(writer);
211     }
212 
213     private BodyContent _bodyContent;
214     private UnsyncStringWriter _unsyncStringWriter;
215 
216 }