KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opensymphony > webwork > views > jsp > ui > WebWorkBodyContent


1 /*
2  * Copyright (c) 2002-2003 by OpenSymphony
3  * All rights reserved.
4  */

5 package com.opensymphony.webwork.views.jsp.ui;
6
7 import javax.servlet.jsp.JspWriter JavaDoc;
8 import javax.servlet.jsp.tagext.BodyContent JavaDoc;
9 import java.io.IOException JavaDoc;
10 import java.io.Reader JavaDoc;
11 import java.io.StringReader JavaDoc;
12 import java.io.Writer JavaDoc;
13
14
15 /**
16  * WebWorkBodyContent
17  * User: jcarreira
18  * Created: Oct 17, 2003 11:18:58 PM
19  */

20 public class WebWorkBodyContent extends BodyContent JavaDoc {
21     //~ Instance fields ////////////////////////////////////////////////////////
22

23     private StringBuffer JavaDoc buffer = new StringBuffer JavaDoc();
24
25     //~ Constructors ///////////////////////////////////////////////////////////
26

27     public WebWorkBodyContent(JspWriter JavaDoc jspWriter) {
28         super(jspWriter);
29     }
30
31     //~ Methods ////////////////////////////////////////////////////////////////
32

33     public Reader JavaDoc getReader() {
34         return new StringReader JavaDoc(buffer.toString());
35     }
36
37     public int getRemaining() {
38         return 0;
39     }
40
41     public String JavaDoc getString() {
42         return buffer.toString();
43     }
44
45     public void clear() throws IOException JavaDoc {
46         buffer = new StringBuffer JavaDoc();
47     }
48
49     public void clearBuffer() throws IOException JavaDoc {
50         clear();
51     }
52
53     public void close() throws IOException JavaDoc {
54         buffer = null;
55     }
56
57     public void newLine() throws IOException JavaDoc {
58         buffer.append("\n");
59     }
60
61     public void print(boolean b) throws IOException JavaDoc {
62         buffer.append(b);
63     }
64
65     public void print(char c) throws IOException JavaDoc {
66         buffer.append(c);
67     }
68
69     public void print(int i) throws IOException JavaDoc {
70         buffer.append(i);
71     }
72
73     public void print(long l) throws IOException JavaDoc {
74         buffer.append(l);
75     }
76
77     public void print(float v) throws IOException JavaDoc {
78         buffer.append(v);
79     }
80
81     public void print(double v) throws IOException JavaDoc {
82         buffer.append(v);
83     }
84
85     public void print(char[] chars) throws IOException JavaDoc {
86         buffer.append(chars);
87     }
88
89     public void print(String JavaDoc s) throws IOException JavaDoc {
90         buffer.append(s);
91     }
92
93     public void print(Object JavaDoc o) throws IOException JavaDoc {
94         buffer.append(o);
95     }
96
97     public void println() throws IOException JavaDoc {
98         newLine();
99     }
100
101     public void println(boolean b) throws IOException JavaDoc {
102         print(b);
103         newLine();
104     }
105
106     public void println(char c) throws IOException JavaDoc {
107         print(c);
108         newLine();
109     }
110
111     public void println(int i) throws IOException JavaDoc {
112         print(i);
113         newLine();
114     }
115
116     public void println(long l) throws IOException JavaDoc {
117         print(l);
118         newLine();
119     }
120
121     public void println(float v) throws IOException JavaDoc {
122         print(v);
123         newLine();
124     }
125
126     public void println(double v) throws IOException JavaDoc {
127         print(v);
128         newLine();
129     }
130
131     public void println(char[] chars) throws IOException JavaDoc {
132         print(chars);
133         newLine();
134     }
135
136     public void println(String JavaDoc s) throws IOException JavaDoc {
137         print(s);
138         newLine();
139     }
140
141     public void println(Object JavaDoc o) throws IOException JavaDoc {
142         print(o);
143         newLine();
144     }
145
146     /**
147      * Write a portion of an array of characters.
148      *
149      * @param cbuf Array of characters
150      * @param off Offset from which to start writing characters
151      * @param len Number of characters to write
152      * @throws IOException If an I/O error occurs
153      */

154     public void write(char[] cbuf, int off, int len) throws IOException JavaDoc {
155         buffer.append(cbuf, off, len);
156     }
157
158     public void writeOut(Writer JavaDoc writer) throws IOException JavaDoc {
159         writer.write(buffer.toString());
160     }
161 }
162
Popular Tags