1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 package org.apache.struts2.views.jsp.ui;
22
23 import java.io.IOException;
24 import java.io.Reader;
25 import java.io.StringReader;
26 import java.io.Writer;
27
28 import javax.servlet.jsp.JspWriter;
29 import javax.servlet.jsp.tagext.BodyContent;
30
31
32 /***
33 * StrutsBodyContent
34 */
35 public class StrutsBodyContent extends BodyContent {
36
37 private StringBuffer buffer = new StringBuffer();
38
39
40 public StrutsBodyContent(JspWriter jspWriter) {
41 super(jspWriter);
42 }
43
44
45 public Reader getReader() {
46 return new StringReader(buffer.toString());
47 }
48
49 public int getRemaining() {
50 return 0;
51 }
52
53 public String getString() {
54 return buffer.toString();
55 }
56
57 public void clear() throws IOException {
58 buffer = new StringBuffer();
59 }
60
61 public void clearBuffer() throws IOException {
62 clear();
63 }
64
65 public void close() throws IOException {
66 buffer = null;
67 }
68
69 public void newLine() throws IOException {
70 buffer.append("\n");
71 }
72
73 public void print(boolean b) throws IOException {
74 buffer.append(b);
75 }
76
77 public void print(char c) throws IOException {
78 buffer.append(c);
79 }
80
81 public void print(int i) throws IOException {
82 buffer.append(i);
83 }
84
85 public void print(long l) throws IOException {
86 buffer.append(l);
87 }
88
89 public void print(float v) throws IOException {
90 buffer.append(v);
91 }
92
93 public void print(double v) throws IOException {
94 buffer.append(v);
95 }
96
97 public void print(char[] chars) throws IOException {
98 buffer.append(chars);
99 }
100
101 public void print(String s) throws IOException {
102 buffer.append(s);
103 }
104
105 public void print(Object o) throws IOException {
106 buffer.append(o);
107 }
108
109 public void println() throws IOException {
110 newLine();
111 }
112
113 public void println(boolean b) throws IOException {
114 print(b);
115 newLine();
116 }
117
118 public void println(char c) throws IOException {
119 print(c);
120 newLine();
121 }
122
123 public void println(int i) throws IOException {
124 print(i);
125 newLine();
126 }
127
128 public void println(long l) throws IOException {
129 print(l);
130 newLine();
131 }
132
133 public void println(float v) throws IOException {
134 print(v);
135 newLine();
136 }
137
138 public void println(double v) throws IOException {
139 print(v);
140 newLine();
141 }
142
143 public void println(char[] chars) throws IOException {
144 print(chars);
145 newLine();
146 }
147
148 public void println(String s) throws IOException {
149 print(s);
150 newLine();
151 }
152
153 public void println(Object o) throws IOException {
154 print(o);
155 newLine();
156 }
157
158 /***
159 * Write a portion of an array of characters.
160 *
161 * @param cbuf Array of characters
162 * @param off Offset from which to start writing characters
163 * @param len Number of characters to write
164 * @throws IOException If an I/O error occurs
165 */
166 public void write(char[] cbuf, int off, int len) throws IOException {
167 buffer.append(cbuf, off, len);
168 }
169
170 public void writeOut(Writer writer) throws IOException {
171 writer.write(buffer.toString());
172 }
173 }