1 28 29 package com.caucho.jsf.context; 30 31 import java.io.*; 32 33 import javax.faces.component.*; 34 import javax.faces.context.*; 35 36 import javax.servlet.http.*; 37 38 public class ResponseWriterImpl extends ResponseWriter 39 { 40 private HttpServletResponse _response; 41 private Writer _out; 42 private boolean _inElement; 43 44 ResponseWriterImpl(HttpServletResponse response, Writer out) 45 { 46 _response = response; 47 _out = out; 48 } 49 50 public void write(char []buffer, int offset, int length) 51 throws IOException 52 { 53 _out.write(buffer, offset, length); 54 } 55 56 public void write(char ch) 57 throws IOException 58 { 59 _out.write(ch); 60 } 61 62 public String getContentType() 63 { 64 return _response.getContentType(); 65 } 66 67 public String getCharacterEncoding() 68 { 69 return _response.getCharacterEncoding(); 70 } 71 72 public void flush() 73 throws IOException 74 { 75 _out.flush(); 76 } 77 78 public void startDocument() 79 throws IOException 80 { 81 } 82 83 public void endDocument() 84 throws IOException 85 { 86 } 87 88 public void startElement(String name, UIComponent component) 89 throws IOException 90 { 91 if (_inElement) 92 closeElement(); 93 94 _out.write("<"); 95 _out.write(name); 96 _inElement = true; 97 } 98 99 public void endElement(String name) 100 throws IOException 101 { 102 if (_inElement) 103 closeElement(); 104 105 _out.write("</"); 106 _out.write(name); 107 _out.write(">"); 108 } 109 110 public void writeAttribute(String name, 111 Object value, 112 String property) 113 throws IOException 114 { 115 _out.write(' '); 116 _out.write(name); 117 _out.write("=\""); 118 _out.write(String.valueOf(value)); 119 _out.write("\""); 120 } 121 122 public void writeURIAttribute(String name, 123 Object value, 124 String property) 125 throws IOException 126 { 127 writeAttribute(name, value, property); 128 } 129 130 public void writeComment(Object comment) 131 throws IOException 132 { 133 if (_inElement) 134 closeElement(); 135 136 _out.write("<!--"); 137 _out.write(String.valueOf(comment)); 138 _out.write("-->"); 139 } 140 141 public void writeText(Object text, 142 String property) 143 throws IOException 144 { 145 if (_inElement) 146 closeElement(); 147 148 _out.write(String.valueOf(text)); 149 } 150 151 public void writeText(char []text, int offset, int length) 152 throws IOException 153 { 154 if (_inElement) 155 closeElement(); 156 157 _out.write(text, offset, length); 158 } 159 160 public ResponseWriter cloneWithWriter(Writer out) 161 { 162 return new ResponseWriterImpl(_response, out); 163 } 164 165 private void closeElement() 166 throws IOException 167 { 168 _out.write(">"); 169 _inElement = false; 170 } 171 172 public void close() 173 throws IOException 174 { 175 } 176 } 177 | Popular Tags |