001: /*
002: * Copyright (c) 2002-2003 by OpenSymphony
003: * All rights reserved.
004: */
005: package com.opensymphony.webwork.views.jsp.ui;
006:
007: import javax.servlet.jsp.JspWriter;
008: import javax.servlet.jsp.tagext.BodyContent;
009: import java.io.IOException;
010: import java.io.Reader;
011: import java.io.StringReader;
012: import java.io.Writer;
013:
014: /**
015: * WebWorkBodyContent
016: * User: jcarreira
017: * Created: Oct 17, 2003 11:18:58 PM
018: */
019: public class WebWorkBodyContent extends BodyContent {
020:
021: private StringBuffer buffer = new StringBuffer();
022:
023: public WebWorkBodyContent(JspWriter jspWriter) {
024: super (jspWriter);
025: }
026:
027: public Reader getReader() {
028: return new StringReader(buffer.toString());
029: }
030:
031: public int getRemaining() {
032: return 0;
033: }
034:
035: public String getString() {
036: return buffer.toString();
037: }
038:
039: public void clear() throws IOException {
040: buffer = new StringBuffer();
041: }
042:
043: public void clearBuffer() throws IOException {
044: clear();
045: }
046:
047: public void close() throws IOException {
048: buffer = null;
049: }
050:
051: public void newLine() throws IOException {
052: buffer.append("\n");
053: }
054:
055: public void print(boolean b) throws IOException {
056: buffer.append(b);
057: }
058:
059: public void print(char c) throws IOException {
060: buffer.append(c);
061: }
062:
063: public void print(int i) throws IOException {
064: buffer.append(i);
065: }
066:
067: public void print(long l) throws IOException {
068: buffer.append(l);
069: }
070:
071: public void print(float v) throws IOException {
072: buffer.append(v);
073: }
074:
075: public void print(double v) throws IOException {
076: buffer.append(v);
077: }
078:
079: public void print(char[] chars) throws IOException {
080: buffer.append(chars);
081: }
082:
083: public void print(String s) throws IOException {
084: buffer.append(s);
085: }
086:
087: public void print(Object o) throws IOException {
088: buffer.append(o);
089: }
090:
091: public void println() throws IOException {
092: newLine();
093: }
094:
095: public void println(boolean b) throws IOException {
096: print(b);
097: newLine();
098: }
099:
100: public void println(char c) throws IOException {
101: print(c);
102: newLine();
103: }
104:
105: public void println(int i) throws IOException {
106: print(i);
107: newLine();
108: }
109:
110: public void println(long l) throws IOException {
111: print(l);
112: newLine();
113: }
114:
115: public void println(float v) throws IOException {
116: print(v);
117: newLine();
118: }
119:
120: public void println(double v) throws IOException {
121: print(v);
122: newLine();
123: }
124:
125: public void println(char[] chars) throws IOException {
126: print(chars);
127: newLine();
128: }
129:
130: public void println(String s) throws IOException {
131: print(s);
132: newLine();
133: }
134:
135: public void println(Object o) throws IOException {
136: print(o);
137: newLine();
138: }
139:
140: /**
141: * Write a portion of an array of characters.
142: *
143: * @param cbuf Array of characters
144: * @param off Offset from which to start writing characters
145: * @param len Number of characters to write
146: * @throws IOException If an I/O error occurs
147: */
148: public void write(char[] cbuf, int off, int len) throws IOException {
149: buffer.append(cbuf, off, len);
150: }
151:
152: public void writeOut(Writer writer) throws IOException {
153: writer.write(buffer.toString());
154: }
155: }
|