| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /** | 5 /** |
| 6 * Basic input stream which supplies binary data. | 6 * Basic input stream which supplies binary data. |
| 7 * | 7 * |
| 8 * Input streams are used to read data sequentially from some data | 8 * Input streams are used to read data sequentially from some data |
| 9 * source. All input streams are non-blocking. They each have a number | 9 * source. All input streams are non-blocking. They each have a number |
| 10 * of read calls which will always return without any IO related | 10 * of read calls which will always return without any IO related |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 69 * stream until the close handler is called, calling [close] is not | 69 * stream until the close handler is called, calling [close] is not |
| 70 * required. When [close] is used the close handler will still be | 70 * required. When [close] is used the close handler will still be |
| 71 * called. | 71 * called. |
| 72 */ | 72 */ |
| 73 void close(); | 73 void close(); |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * Returns whether the stream is closed. There will be no more data | 76 * Returns whether the stream is closed. There will be no more data |
| 77 * to read. | 77 * to read. |
| 78 */ | 78 */ |
| 79 bool get closed(); | 79 bool get closed; |
| 80 | 80 |
| 81 /** | 81 /** |
| 82 * Sets the handler that gets called when data is available. | 82 * Sets the handler that gets called when data is available. |
| 83 */ | 83 */ |
| 84 void set onData(void callback()); | 84 void set onData(void callback()); |
| 85 | 85 |
| 86 /** | 86 /** |
| 87 * Sets the handler that gets called when there will be no more data | 87 * Sets the handler that gets called when there will be no more data |
| 88 * available in the stream. | 88 * available in the stream. |
| 89 */ | 89 */ |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 * characters. If [readLine] is used for reading one can observe | 141 * characters. If [readLine] is used for reading one can observe |
| 142 * less characters being returned as the line breaking characters | 142 * less characters being returned as the line breaking characters |
| 143 * are discarded. | 143 * are discarded. |
| 144 */ | 144 */ |
| 145 int available(); | 145 int available(); |
| 146 | 146 |
| 147 /** | 147 /** |
| 148 * Returns whether the stream has been closed. There might still be | 148 * Returns whether the stream has been closed. There might still be |
| 149 * more data to read. | 149 * more data to read. |
| 150 */ | 150 */ |
| 151 bool get closed(); | 151 bool get closed; |
| 152 | 152 |
| 153 /** | 153 /** |
| 154 * Returns the encoding used to decode the binary data into characters. | 154 * Returns the encoding used to decode the binary data into characters. |
| 155 */ | 155 */ |
| 156 Encoding get encoding(); | 156 Encoding get encoding; |
| 157 | 157 |
| 158 /** | 158 /** |
| 159 * Sets the handler that gets called when data is available. The two | 159 * Sets the handler that gets called when data is available. The two |
| 160 * handlers [onData] and [onLine] are mutually exclusive | 160 * handlers [onData] and [onLine] are mutually exclusive |
| 161 * and setting one will remove the other. | 161 * and setting one will remove the other. |
| 162 */ | 162 */ |
| 163 void set onData(void callback()); | 163 void set onData(void callback()); |
| 164 | 164 |
| 165 /** | 165 /** |
| 166 * Sets the handler that gets called when a line is available. The | 166 * Sets the handler that gets called when a line is available. The |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 * Reads [chunkSize] bytes from the stream. If [chunkSize] bytes are | 198 * Reads [chunkSize] bytes from the stream. If [chunkSize] bytes are |
| 199 * not currently available null is returned. When the stream is | 199 * not currently available null is returned. When the stream is |
| 200 * closed the last call can return with less than [chunkSize] bytes. | 200 * closed the last call can return with less than [chunkSize] bytes. |
| 201 */ | 201 */ |
| 202 List<int> read(); | 202 List<int> read(); |
| 203 | 203 |
| 204 /** | 204 /** |
| 205 * Returns whether the stream has been closed. There might still be | 205 * Returns whether the stream has been closed. There might still be |
| 206 * more data to read. | 206 * more data to read. |
| 207 */ | 207 */ |
| 208 bool get closed(); | 208 bool get closed; |
| 209 | 209 |
| 210 /** | 210 /** |
| 211 * Returns the chunk size used by this stream. | 211 * Returns the chunk size used by this stream. |
| 212 */ | 212 */ |
| 213 int get chunkSize(); | 213 int get chunkSize; |
| 214 | 214 |
| 215 /** | 215 /** |
| 216 * Sets the chunk size used by this stream. | 216 * Sets the chunk size used by this stream. |
| 217 */ | 217 */ |
| 218 void set chunkSize(int chunkSize); | 218 void set chunkSize(int chunkSize); |
| 219 | 219 |
| 220 /** | 220 /** |
| 221 * Sets the handler that gets called when at least [chunkSize] bytes | 221 * Sets the handler that gets called when at least [chunkSize] bytes |
| 222 * of data is available or the underlying stream has been closed and | 222 * of data is available or the underlying stream has been closed and |
| 223 * there is still unread data. | 223 * there is still unread data. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 237 void set onError(void callback(e)); | 237 void set onError(void callback(e)); |
| 238 } | 238 } |
| 239 | 239 |
| 240 | 240 |
| 241 class StreamException implements Exception { | 241 class StreamException implements Exception { |
| 242 const StreamException([String this.message = ""]); | 242 const StreamException([String this.message = ""]); |
| 243 const StreamException.streamClosed() : message = "Stream closed"; | 243 const StreamException.streamClosed() : message = "Stream closed"; |
| 244 String toString() => "StreamException: $message"; | 244 String toString() => "StreamException: $message"; |
| 245 final String message; | 245 final String message; |
| 246 } | 246 } |
| OLD | NEW |