1 28 29 package com.caucho.jsp; 30 31 import javax.servlet.jsp.JspWriter ; 32 import java.io.IOException ; 33 import java.io.PrintWriter ; 34 import java.io.Writer ; 35 36 39 class StreamJspWriter extends AbstractBodyContent { 40 private Writer _writer; 42 43 private JspPrintWriter _printWriter; 44 45 private JspWriter _parent; 46 47 private PageContextImpl _pageContext; 49 50 private boolean _isClosed; 51 52 55 StreamJspWriter() 56 { 57 } 58 59 64 void init(JspWriter parent, Writer writer) 65 { 66 _parent = parent; 67 _writer = writer; 68 _isClosed = false; 69 } 70 71 74 public PrintWriter getWriter() 75 { 76 if (_printWriter == null) 77 _printWriter = new JspPrintWriter(this); 78 79 _printWriter.init(this); 80 81 return _printWriter; 82 } 83 84 91 final public void write(char []buf, int offset, int length) 92 throws IOException 93 { 94 if (_isClosed) 95 return; 96 97 _writer.write(buf, offset, length); 98 } 99 100 105 final public void write(int ch) throws IOException 106 { 107 if (_isClosed) 108 return; 109 110 _writer.write(ch); 111 } 112 113 116 final public void newLine() throws IOException 117 { 118 if (_isClosed) 119 return; 120 121 _writer.write('\n'); 122 } 123 124 127 final public void print(char ch) throws IOException 128 { 129 if (_isClosed) 130 return; 131 132 _writer.write(ch); 133 } 134 135 138 final public void println() throws IOException 139 { 140 _writer.write('\n'); 141 } 142 143 public void clear() throws IOException 144 { 145 clearBuffer(); 146 } 147 148 public void clearBuffer() throws IOException 149 { 150 } 151 152 public void flushBuffer() 153 throws IOException 154 { 155 if (_isClosed) 156 return; 157 158 _writer.flush(); 159 } 160 161 public void flush() throws IOException 162 { 163 _writer.flush(); 164 } 165 166 final public void close() throws IOException 167 { 168 _isClosed = true; 169 } 170 171 public int getBufferSize() 172 { 173 return 0; 174 } 175 176 public int getRemaining() 177 { 178 return 0; 179 } 180 181 AbstractJspWriter popWriter() 182 { 183 AbstractJspWriter parent = super.popWriter(); 184 185 return parent; 186 } 187 } 188 | Popular Tags |