001 package railo.runtime.writer; 002 003 import java.io.IOException; 004 005 import javax.servlet.http.HttpServletRequest; 006 import javax.servlet.http.HttpServletResponse; 007 008 /** 009 * JSP Writer that Remove WhiteSpace from given content 010 */ 011 public abstract class AbstrCFMLWriterWS extends CFMLWriterImpl implements WhiteSpaceWriter { 012 013 public static final char CHAR_EMPTY=0; 014 public static final char CHAR_NL='\n'; 015 public static final char CHAR_SPACE=' '; 016 public static final char CHAR_TAB='\t'; 017 public static final char CHAR_BS='\b'; // \x0B\ 018 public static final char CHAR_FW='\f'; 019 public static final char CHAR_RETURN='\r'; 020 021 char charBuffer=CHAR_EMPTY; 022 023 /** 024 * constructor of the class 025 * @param rsp 026 * @param bufferSize 027 * @param autoFlush 028 */ 029 public AbstrCFMLWriterWS(HttpServletRequest req, HttpServletResponse rsp, int bufferSize, boolean autoFlush, boolean closeConn, 030 boolean showVersion, boolean contentLength, boolean allowCompression) { 031 super(req,rsp, bufferSize, autoFlush,closeConn,showVersion,contentLength,allowCompression); 032 } 033 034 035 /** 036 * @see railo.runtime.writer.CFMLWriterImpl#clear() 037 */ 038 public final void clear() throws IOException { 039 printBuffer(); 040 super.clear(); 041 } 042 043 /** 044 * @see railo.runtime.writer.CFMLWriterImpl#clearBuffer() 045 */ 046 public final void clearBuffer() { 047 printBufferEL(); 048 super.clearBuffer(); 049 } 050 051 /** 052 * @see railo.runtime.writer.CFMLWriterImpl#close() 053 */ 054 public final void close() throws IOException { 055 printBuffer(); 056 super.close(); 057 } 058 059 /** 060 * @see railo.runtime.writer.CFMLWriterImpl#flush() 061 */ 062 public final void flush() throws IOException { 063 printBuffer(); 064 super.flush(); 065 } 066 067 /** 068 * @see railo.runtime.writer.CFMLWriterImpl#getRemaining() 069 */ 070 public final int getRemaining() { 071 printBufferEL(); 072 return super.getRemaining(); 073 } 074 075 /** 076 * @see railo.runtime.writer.CFMLWriterImpl#newLine() 077 */ 078 public final void newLine() throws IOException { 079 print(CHAR_NL); 080 } 081 082 /** 083 * @see railo.runtime.writer.CFMLWriterImpl#print(boolean) 084 */ 085 public final void print(boolean b) throws IOException { 086 printBuffer(); 087 super.print(b); 088 } 089 090 /** 091 * @see railo.runtime.writer.CFMLWriterImpl#print(char[]) 092 */ 093 public final void print(char[] chars) throws IOException { 094 write(chars,0,chars.length); 095 } 096 097 /** 098 * @see railo.runtime.writer.CFMLWriterImpl#print(double) 099 */ 100 public final void print(double d) throws IOException { 101 printBuffer(); 102 super.print(d); 103 } 104 105 /** 106 * @see railo.runtime.writer.CFMLWriterImpl#print(float) 107 */ 108 public final void print(float f) throws IOException { 109 printBuffer(); 110 super.print(f); 111 } 112 113 /** 114 * @see railo.runtime.writer.CFMLWriterImpl#print(int) 115 */ 116 public final void print(int i) throws IOException { 117 printBuffer(); 118 super.print(i); 119 } 120 121 /** 122 * @see railo.runtime.writer.CFMLWriterImpl#print(long) 123 */ 124 public final void print(long l) throws IOException { 125 printBuffer(); 126 super.print(l); 127 } 128 129 /** 130 * @see railo.runtime.writer.CFMLWriterImpl#print(java.lang.Object) 131 */ 132 public final void print(Object obj) throws IOException { 133 print(obj.toString()); 134 } 135 136 /** 137 * @see railo.runtime.writer.CFMLWriterImpl#print(java.lang.String) 138 */ 139 public final void print(String str) throws IOException { 140 write(str.toCharArray(),0,str.length()); 141 } 142 143 /** 144 * @see railo.runtime.writer.CFMLWriterImpl#println() 145 */ 146 public final void println() throws IOException { 147 print(CHAR_NL); 148 } 149 150 /** 151 * @see railo.runtime.writer.CFMLWriterImpl#println(boolean) 152 */ 153 public final void println(boolean b) throws IOException { 154 printBuffer(); 155 super.print(b); 156 print(CHAR_NL); 157 } 158 159 /** 160 * @see railo.runtime.writer.CFMLWriterImpl#println(char) 161 */ 162 public final void println(char c) throws IOException { 163 print(c); 164 print(CHAR_NL); 165 } 166 167 /** 168 * @see railo.runtime.writer.CFMLWriterImpl#println(char[]) 169 */ 170 public final void println(char[] chars) throws IOException { 171 write(chars,0,chars.length); 172 print(CHAR_NL); 173 } 174 175 /** 176 * @see railo.runtime.writer.CFMLWriterImpl#println(double) 177 */ 178 public final void println(double d) throws IOException { 179 printBuffer(); 180 super.print(d); 181 print(CHAR_NL); 182 } 183 184 /** 185 * @see railo.runtime.writer.CFMLWriterImpl#println(float) 186 */ 187 public final void println(float f) throws IOException { 188 printBuffer(); 189 super.print(f); 190 print(CHAR_NL); 191 } 192 193 /** 194 * @see railo.runtime.writer.CFMLWriterImpl#println(int) 195 */ 196 public final void println(int i) throws IOException { 197 printBuffer(); 198 super.print(i); 199 print(CHAR_NL); 200 } 201 202 /** 203 * @see railo.runtime.writer.CFMLWriterImpl#println(long) 204 */ 205 public final void println(long l) throws IOException { 206 printBuffer(); 207 super.print(l); 208 print(CHAR_NL); 209 } 210 211 /** 212 * @see railo.runtime.writer.CFMLWriterImpl#println(java.lang.Object) 213 */ 214 public final void println(Object obj) throws IOException { 215 println(obj.toString()); 216 } 217 218 /** 219 * @see railo.runtime.writer.CFMLWriterImpl#println(java.lang.String) 220 */ 221 public final void println(String str) throws IOException { 222 print(str); 223 print(CHAR_NL); 224 225 } 226 227 /** 228 * @see railo.runtime.writer.CFMLWriterImpl#write(char[], int, int) 229 */ 230 public final void write(char[] chars, int off, int len) throws IOException { 231 for(int i=off;i<len;i++) { 232 print(chars[i]); 233 } 234 } 235 236 /** 237 * @see railo.runtime.writer.CFMLWriterImpl#write(java.lang.String, int, int) 238 */ 239 public final void write(String str, int off, int len) throws IOException { 240 write(str.toCharArray(),off,len); 241 } 242 243 244 /** 245 * @see railo.runtime.writer.CFMLWriterImpl#write(char[]) 246 */ 247 public final void write(char[] chars) throws IOException { 248 write(chars,0,chars.length); 249 } 250 251 /** 252 * @see railo.runtime.writer.CFMLWriterImpl#write(int) 253 */ 254 public final void write(int i) throws IOException { 255 print(i); 256 } 257 258 /** 259 * @see railo.runtime.writer.CFMLWriterImpl#write(java.lang.String) 260 */ 261 public final void write(String str) throws IOException { 262 write(str.toCharArray(),0,str.length()); 263 } 264 265 abstract void printBuffer() throws IOException; 266 abstract void printBufferEL(); 267 }