| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 * Input streams are used to read data sequentially from some data | 6 * Input streams are used to read data sequentially from some data |
| 7 * source. All input streams are non-blocking. They each have a number | 7 * source. All input streams are non-blocking. They each have a number |
| 8 * of read calls which will always return without any IO related | 8 * of read calls which will always return without any IO related |
| 9 * blocking. If the requested data is not available a read call will | 9 * blocking. If the requested data is not available a read call will |
| 10 * return [:null:]. All input streams have one or more handlers which | 10 * return [:null:]. All input streams have one or more handlers which |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 StringInputStream(InputStream input, [String encoding]); | 113 StringInputStream(InputStream input, [String encoding]); |
| 114 | 114 |
| 115 /** | 115 /** |
| 116 * Reads as many characters as is available from the stream. If no data is | 116 * Reads as many characters as is available from the stream. If no data is |
| 117 * available null will be returned. | 117 * available null will be returned. |
| 118 */ | 118 */ |
| 119 String read(); | 119 String read(); |
| 120 | 120 |
| 121 /** | 121 /** |
| 122 * Reads the next line from the stream. The line ending characters | 122 * Reads the next line from the stream. The line ending characters |
| 123 * will not be part og the returned string. If a full line is not | 123 * will not be part of the returned string. If a full line is not |
| 124 * available null will be returned. The line break character(s) are | 124 * available null will be returned. |
| 125 * discarded. | |
| 126 */ | 125 */ |
| 127 String readLine(); | 126 String readLine(); |
| 128 | 127 |
| 129 /** | 128 /** |
| 130 * Returns whether the stream has been closed. There might still be | 129 * Returns whether the stream has been closed. There might still be |
| 131 * more data to read. | 130 * more data to read. |
| 132 */ | 131 */ |
| 133 bool get closed(); | 132 bool get closed(); |
| 134 | 133 |
| 135 /** | 134 /** |
| 136 * Returns the encoding used to decode the binary data into characters. | 135 * Returns the encoding used to decode the binary data into characters. |
| 137 */ | 136 */ |
| 138 String get encoding(); | 137 String get encoding(); |
| 139 | 138 |
| 140 /** | 139 /** |
| 141 * Sets the handler that gets called when data is available. The two | 140 * Sets the handler that gets called when data is available. The two |
| 142 * handlers [dataHandler} and [lineHandler] are mutually exclusive | 141 * handlers [dataHandler] and [lineHandler] are mutually exclusive |
| 143 * and setting one will remove the other. | 142 * and setting one will remove the other. |
| 144 */ | 143 */ |
| 145 void set dataHandler(void callback()); | 144 void set dataHandler(void callback()); |
| 146 | 145 |
| 147 /** | 146 /** |
| 148 * Sets the handler that gets called when a line is available. The | 147 * Sets the handler that gets called when a line is available. The |
| 149 * two handlers [dataHandler} and [lineHandler] are mutually | 148 * two handlers [dataHandler] and [lineHandler] are mutually |
| 150 * exclusive and setting one will remove the other. | 149 * exclusive and setting one will remove the other. |
| 151 */ | 150 */ |
| 152 void set lineHandler(void callback()); | 151 void set lineHandler(void callback()); |
| 153 | 152 |
| 154 /** | 153 /** |
| 155 * Sets the handler that gets called when there will be no more data | 154 * Sets the handler that gets called when there will be no more data |
| 156 * available in the stream. | 155 * available in the stream. |
| 157 */ | 156 */ |
| 158 void set closeHandler(void callback()); | 157 void set closeHandler(void callback()); |
| 159 | 158 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 void set errorHandler(void callback()); | 218 void set errorHandler(void callback()); |
| 220 } | 219 } |
| 221 | 220 |
| 222 | 221 |
| 223 class StreamException implements Exception { | 222 class StreamException implements Exception { |
| 224 const StreamException([String this.message = ""]); | 223 const StreamException([String this.message = ""]); |
| 225 const StreamException.streamClosed() : message = "Stream closed"; | 224 const StreamException.streamClosed() : message = "Stream closed"; |
| 226 String toString() => "StreamException: $message"; | 225 String toString() => "StreamException: $message"; |
| 227 final String message; | 226 final String message; |
| 228 } | 227 } |
| OLD | NEW |