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