1 29 30 package com.caucho.server.hmux; 31 32 import com.caucho.log.Log; 33 import com.caucho.vfs.StreamImpl; 34 35 import java.io.IOException ; 36 import java.net.SocketException ; 37 import java.util.Iterator ; 38 import java.util.logging.Logger ; 39 40 43 class HmuxStreamWrapper extends StreamImpl { 44 private static final Logger log = Log.open(HmuxStream.class); 45 46 private HmuxStream _stream; 47 48 51 HmuxStreamWrapper(HmuxStream stream) 52 throws IOException 53 { 54 _stream = stream; 55 } 56 57 60 public void setSSL(boolean isSSL) 61 { 62 _stream.setSSL(isSSL); 63 } 64 65 68 public boolean isSSL() 69 { 70 return _stream.isSSL(); 71 } 72 73 76 public void setMethod(String method) 77 { 78 _stream.setMethod(method); 79 } 80 81 84 public void setHead(boolean isHead) 85 { 86 _stream.setHead(isHead); 87 } 88 89 92 public String getHost() 93 { 94 return _stream.getHost(); 95 } 96 97 100 public int getPort() 101 { 102 return _stream.getPort(); 103 } 104 105 111 public Object getAttribute(String name) 112 throws IOException 113 { 114 if (_stream != null) 115 return _stream.getAttribute(name); 116 else 117 return null; 118 } 119 120 123 public Iterator getAttributeNames() 124 throws IOException 125 { 126 if (_stream != null) 127 return _stream.getAttributeNames(); 128 else 129 return null; 130 } 131 132 135 public void setAttribute(String name, Object value) 136 { 137 if (_stream != null) 138 _stream.setAttribute(name, value); 139 } 140 141 144 public void removeAttribute(String name) 145 { 146 if (_stream != null) 147 _stream.removeAttribute(name); 148 } 149 150 153 public void setSocketTimeout(long timeout) 154 throws SocketException 155 { 156 if (_stream != null) 157 _stream.setSocketTimeout(timeout); 158 } 159 160 163 public boolean canWrite() 164 { 165 if (_stream != null) 166 return _stream.canWrite(); 167 else 168 return false; 169 } 170 171 179 public void write(byte []buf, int offset, int length, boolean isEnd) 180 throws IOException 181 { 182 if (_stream != null) 183 _stream.write(buf, offset, length, isEnd); 184 } 185 186 189 public boolean canRead() 190 { 191 if (_stream != null) 192 return _stream.canRead(); 193 else 194 return false; 195 } 196 197 201 public int read(byte []buf, int offset, int length) throws IOException 202 { 203 if (_stream != null) 204 return _stream.read(buf, offset, length); 205 else 206 return -1; 207 } 208 209 212 public int getAvailable() throws IOException 213 { 214 if (_stream != null) 215 return _stream.getAvailable(); 216 else 217 return -1; 218 } 219 220 223 public void close() throws IOException 224 { 225 HmuxStream stream = _stream; 226 _stream = null; 227 228 if (stream != null) 229 stream.close(); 230 } 231 } 232 | Popular Tags |