1 package com.quadcap.http.server22; 2 3 40 41 import java.io.IOException ; 42 43 import com.quadcap.io.IO; 44 45 52 public class JspWriter extends javax.servlet.jsp.JspWriter { 53 HttpOutputStream out; 54 boolean closed = false; 55 byte[] buf = null; 56 static String lineSep = System.getProperty("line.separator"); 57 58 public JspWriter(int bufferSize, boolean autoFlush) { 59 super(bufferSize, autoFlush); 60 } 61 62 final void setHttpOutputStream(HttpOutputStream out) { 63 this.out = out; 64 } 65 66 public final void newLine() throws IOException { 67 print(lineSep); 68 } 69 70 public final void print(boolean b) throws IOException { 71 print(b ? "true" : "false"); 72 } 73 74 public final void print(char c) throws IOException { 75 print(String.valueOf(c)); 76 } 77 78 public final void print(int i) throws IOException { 79 print(String.valueOf(i)); 80 } 81 82 public final void print(long l) throws IOException { 83 print(String.valueOf(l)); 84 } 85 86 public final void print(float f) throws IOException { 87 print(String.valueOf(f)); 88 } 89 90 public final void print(double d) throws IOException { 91 print(String.valueOf(d)); 92 } 93 94 public final void print(char[] ch) throws IOException { 95 write(ch, 0, ch.length); 96 } 97 98 public final void print(String s) throws IOException { 99 final int len = s.length(); 100 if (buf == null || buf.length < len) { 101 buf = new byte[len]; 102 } 103 for (int i = 0; i < len; i++) { 104 buf[i] = (byte)(s.charAt(i) & 0xff); 105 } 106 out.write(buf, 0, len); 107 } 108 109 public final void write(String s) throws IOException { 110 IO.write(out, s); 111 } 112 113 public final void write(String s, int off, int len) throws IOException { 114 for (int i = 0; i < len; i++) { 115 out.write(s.charAt(off + i) & 0xff); 116 } 117 } 118 119 public final void print(Object obj) throws IOException { 120 print(obj.toString()); 121 } 122 123 public final void println() throws IOException { 124 print(lineSep); 125 } 126 127 public final void println(boolean b) throws IOException { 128 print(b); 129 println(); 130 } 131 132 public final void println(char c) throws IOException { 133 print(c); 134 println(); 135 } 136 137 public final void println(int i) throws IOException { 138 print(i); 139 println(); 140 } 141 142 public final void println(long l) throws IOException { 143 print(l); 144 println(); 145 } 146 147 public final void println(float f) throws IOException { 148 print(f); 149 println(); 150 } 151 152 public final void println(double d) throws IOException { 153 print(d); 154 println(); 155 } 156 157 public final void println(char[] ch) throws IOException { 158 print(ch); 159 println(); 160 } 161 162 public final void println(String s) throws IOException { 163 print(s); 164 println(); 165 } 166 167 public final void println(Object obj) throws IOException { 168 print(obj); 169 println(); 170 } 171 172 public final void write(char[] ch, int off, int len) throws IOException { 173 if (closed) throw new IOException ("JspWriter closed"); 174 for (int i = 0; i < len; i++) { 175 out.write(ch[off + i]); 176 } 177 } 178 179 public final void clear() throws IOException { 180 try { 181 out.reset(); 182 } catch (IllegalStateException e) { 183 throw new IOException (e.toString()); 184 } 185 } 186 187 public final void clearBuffer() throws IOException { 188 try { 189 out.reset(); 190 } catch (IllegalStateException e) {} 191 } 192 193 public final void flush() throws IOException { 194 out.flush(); 195 } 196 197 public final void close() throws IOException { 198 if (!closed) { 199 out.close(); 200 closed = true; 201 } 202 } 203 204 public final int getRemaining() { 205 return out.getRemaining(); 206 } 207 208 public final void setBufferSize(int bufferSize) { 209 out.setBufferSize(bufferSize); 210 } 211 212 public final void setAutoFlush(boolean autoFlush) { 213 out.setAutoFlush(autoFlush); 214 } 215 } 216 217 | Popular Tags |