00001
package com.quadcap.http.servlets.jsp;
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
import java.io.CharArrayWriter;
00042
import java.io.IOException;
00043
import java.io.PrintWriter;
00044
import java.io.Writer;
00045
00046
00047
00048
00049
00050
00051
00052 public class JspWriter extends javax.servlet.jsp.
JspWriter {
00053 CharArrayWriter
w;
00054 Writer
out;
00055 int written = 0;
00056 boolean flushed =
false;
00057 boolean closed =
false;
00058 static String
lineSep = System.getProperty(
"line.separator");
00059
00060 public JspWriter(Writer out,
int bufferSize,
boolean autoFlush) {
00061 super(bufferSize, autoFlush);
00062
this.out = out;
00063
w =
new CharArrayWriter();
00064 }
00065
00066 public void newLine() throws IOException {
00067
print(
lineSep);
00068 }
00069
00070 public void print(
boolean b)
throws IOException {
00071 print(b ?
"true" :
"false");
00072 }
00073
00074 public void print(
char c)
throws IOException {
00075 print(String.valueOf(c));
00076 }
00077
00078 public void print(
int i)
throws IOException {
00079 print(String.valueOf(i));
00080 }
00081
00082 public void print(
long l)
throws IOException {
00083 print(String.valueOf(l));
00084 }
00085
00086 public void print(
float f)
throws IOException {
00087 print(String.valueOf(f));
00088 }
00089
00090 public void print(
double d)
throws IOException {
00091 print(String.valueOf(d));
00092 }
00093
00094 public void print(
char[] ch)
throws IOException {
00095
write(ch, 0, ch.length);
00096 }
00097
00098 public void print(String s)
throws IOException {
00099
w.write(s, 0, s.length());
00100 }
00101
00102 public void print(Object obj)
throws IOException {
00103 print(obj.toString());
00104 }
00105
00106 public void println() throws IOException {
00107 print(
lineSep);
00108 }
00109
00110 public void println(
boolean b)
throws IOException {
00111 print(b);
00112
println();
00113 }
00114
00115 public void println(
char c)
throws IOException {
00116 print(c);
00117
println();
00118 }
00119
00120 public void println(
int i)
throws IOException {
00121 print(i);
00122
println();
00123 }
00124
00125 public void println(
long l)
throws IOException {
00126 print(l);
00127
println();
00128 }
00129
00130 public void println(
float f)
throws IOException {
00131 print(f);
00132
println();
00133 }
00134
00135 public void println(
double d)
throws IOException {
00136 print(d);
00137
println();
00138 }
00139
00140 public void println(
char[] ch)
throws IOException {
00141 print(ch);
00142
println();
00143 }
00144
00145 public void println(String s)
throws IOException {
00146 print(s);
00147
println();
00148 }
00149
00150 public void println(Object obj)
throws IOException {
00151 print(obj);
00152
println();
00153 }
00154
00155 public void write(
char[] ch,
int off,
int len)
throws IOException {
00156
if (
closed)
throw new IOException(
"JspWriter closed");
00157
if (
written + len > getBufferSize()) {
00158
if (autoFlush) {
00159
flush();
00160
w.reset();
00161
flushed =
true;
00162 }
else {
00163
throw new IOException(
"JspWriter: buffer full");
00164 }
00165 }
00166
w.write(ch, off, len);
00167 }
00168
00169 public void clear() throws IOException {
00170
w.reset();
00171 }
00172
00173 public void clearBuffer() throws IOException {
00174
if (
flushed)
throw new IOException(
"JspWriter already flushed");
00175
w.reset();
00176 }
00177
00178 public void flush() throws IOException {
00179
w.writeTo(
out);
00180 }
00181
00182 public void close() throws IOException {
00183
if (!
closed) {
00184
flush();
00185
closed =
true;
00186 }
00187 }
00188
00189 public int getRemaining() {
00190
if (
flushed)
return 0;
00191
return getBufferSize() -
w.size();
00192 }
00193 }
00194