Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(297)

Side by Side Diff: runtime/bin/input_stream.dart

Issue 9500002: Rename blahHandler to onBlah throughout dart:io. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Revert temporary edit Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
11 * blocking. If the requested data is not available a read call will 11 * blocking. If the requested data is not available a read call will
12 * return [:null:]. All input streams have one or more handlers which 12 * return [:null:]. All input streams have one or more handlers which
13 * will trigger when data is available. 13 * will trigger when data is available.
14 * 14 *
15 * The following example shows a data handler in an ordinary input 15 * The following example shows a data handler in an ordinary input
16 * stream which will be called when some data is available and a call 16 * stream which will be called when some data is available and a call
17 * to read will not return [:null:]. 17 * to read will not return [:null:].
18 * 18 *
19 * [: 19 * [:
20 * InputStream input = ... 20 * InputStream input = ...
21 * input.dataHandler = () { 21 * input.onData = () {
22 * var data = input.read(); 22 * var data = input.read();
23 * ... 23 * ...
24 * }; 24 * };
25 * :] 25 * :]
26 * 26 *
27 * If for some reason the data from an input stream cannot be handled 27 * If for some reason the data from an input stream cannot be handled
28 * by the application immediately setting the data handler to [:null:] 28 * by the application immediately setting the data handler to [:null:]
29 * will avoid further callbacks until it is set to a function 29 * will avoid further callbacks until it is set to a function
30 * again. While the data handler is not active system flow control 30 * again. While the data handler is not active system flow control
31 * will be used to avoid buffering more data than needed. 31 * will be used to avoid buffering more data than needed.
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 /** 77 /**
78 * Returns whether the stream is closed. There will be no more data 78 * Returns whether the stream is closed. There will be no more data
79 * to read. 79 * to read.
80 */ 80 */
81 bool get closed(); 81 bool get closed();
82 82
83 /** 83 /**
84 * Sets the handler that gets called when data is available. 84 * Sets the handler that gets called when data is available.
85 */ 85 */
86 void set dataHandler(void callback()); 86 void set onData(void callback());
87 87
88 /** 88 /**
89 * Sets the handler that gets called when there will be no more data 89 * Sets the handler that gets called when there will be no more data
90 * available in the stream. 90 * available in the stream.
91 */ 91 */
92 void set closeHandler(void callback()); 92 void set onClose(void callback());
Søren Gjesse 2012/02/29 07:41:24 onClosed?
93 93
94 /** 94 /**
95 * Sets the handler that gets called when the underlying 95 * Sets the handler that gets called when the underlying
96 * communication channel gets into some kind of error situation. 96 * communication channel gets into some kind of error situation.
97 */ 97 */
98 void set errorHandler(void callback()); 98 void set onError(void callback());
99 } 99 }
100 100
101 101
102 /** 102 /**
103 * A string input stream wraps a basic input stream and supplies 103 * A string input stream wraps a basic input stream and supplies
104 * string data. This data can be read either as string chunks or as 104 * string data. This data can be read either as string chunks or as
105 * lines separated by line termination character sequences. 105 * lines separated by line termination character sequences.
106 */ 106 */
107 interface StringInputStream default _StringInputStream { 107 interface StringInputStream default _StringInputStream {
108 /** 108 /**
(...skipping 21 matching lines...) Expand all
130 */ 130 */
131 bool get closed(); 131 bool get closed();
132 132
133 /** 133 /**
134 * Returns the encoding used to decode the binary data into characters. 134 * Returns the encoding used to decode the binary data into characters.
135 */ 135 */
136 String get encoding(); 136 String get encoding();
137 137
138 /** 138 /**
139 * Sets the handler that gets called when data is available. The two 139 * Sets the handler that gets called when data is available. The two
140 * handlers [dataHandler] and [lineHandler] are mutually exclusive 140 * handlers [onData] and [onLine] are mutually exclusive
141 * and setting one will remove the other. 141 * and setting one will remove the other.
142 */ 142 */
143 void set dataHandler(void callback()); 143 void set onData(void callback());
144 144
145 /** 145 /**
146 * Sets the handler that gets called when a line is available. The 146 * Sets the handler that gets called when a line is available. The
147 * two handlers [dataHandler] and [lineHandler] are mutually 147 * two handlers [onData] and [onLine] are mutually
148 * exclusive and setting one will remove the other. 148 * exclusive and setting one will remove the other.
149 */ 149 */
150 void set lineHandler(void callback()); 150 void set onLine(void callback());
151 151
152 /** 152 /**
153 * Sets the handler that gets called when there will be no more data 153 * Sets the handler that gets called when there will be no more data
154 * available in the stream. 154 * available in the stream.
155 */ 155 */
156 void set closeHandler(void callback()); 156 void set onClose(void callback());
Søren Gjesse 2012/02/29 07:41:24 onClosed?
157 157
158 /** 158 /**
159 * Sets the handler that gets called when the underlying 159 * Sets the handler that gets called when the underlying
160 * communication channel gets into some kind of error situation. 160 * communication channel gets into some kind of error situation.
161 */ 161 */
162 void set errorHandler(void callback()); 162 void set onError(void callback());
163 } 163 }
164 164
165 165
166 /** 166 /**
167 * A chunked input stream wraps a basic input stream and supplies 167 * A chunked input stream wraps a basic input stream and supplies
168 * binary data in configurable chunk sizes. 168 * binary data in configurable chunk sizes.
169 */ 169 */
170 interface ChunkedInputStream default _ChunkedInputStream { 170 interface ChunkedInputStream default _ChunkedInputStream {
171 /** 171 /**
172 * Adds buffering to an input stream and provide the ability to read 172 * Adds buffering to an input stream and provide the ability to read
(...skipping 22 matching lines...) Expand all
195 /** 195 /**
196 * Sets the chunk size used by this stream. 196 * Sets the chunk size used by this stream.
197 */ 197 */
198 void set chunkSize(int chunkSize); 198 void set chunkSize(int chunkSize);
199 199
200 /** 200 /**
201 * Sets the handler that gets called when at least [chunkSize] bytes 201 * Sets the handler that gets called when at least [chunkSize] bytes
202 * of data is available or the underlying stream has been closed and 202 * of data is available or the underlying stream has been closed and
203 * there is still unread data. 203 * there is still unread data.
204 */ 204 */
205 void set dataHandler(void callback()); 205 void set onData(void callback());
206 206
207 /** 207 /**
208 * Sets the handler that gets called when there will be no more data 208 * Sets the handler that gets called when there will be no more data
209 * available in the stream. 209 * available in the stream.
210 */ 210 */
211 void set closeHandler(void callback()); 211 void set onClose(void callback());
Søren Gjesse 2012/02/29 07:41:24 onClosed?
212 212
213 /** 213 /**
214 * Sets the handler that gets called when the underlying 214 * Sets the handler that gets called when the underlying
215 * communication channel gets into some kind of error situation. 215 * communication channel gets into some kind of error situation.
216 */ 216 */
217 void set errorHandler(void callback()); 217 void set onError(void callback());
218 } 218 }
219 219
220 220
221 class StreamException implements Exception { 221 class StreamException implements Exception {
222 const StreamException([String this.message = ""]); 222 const StreamException([String this.message = ""]);
223 const StreamException.streamClosed() : message = "Stream closed"; 223 const StreamException.streamClosed() : message = "Stream closed";
224 String toString() => "StreamException: $message"; 224 String toString() => "StreamException: $message";
225 final String message; 225 final String message;
226 } 226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698