| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 part of dart.io; | 5 part of dart.io; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * A combined byte and text output. | 8 * A combined byte and text output. |
| 9 * | 9 * |
| 10 * An [IOSink] combines a [StreamSink] of bytes with a [StringSink], | 10 * An [IOSink] combines a [StreamSink] of bytes with a [StringSink], |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 final Completer _doneCompleter = new Completer(); | 141 final Completer _doneCompleter = new Completer(); |
| 142 StreamController<T> _controllerInstance; | 142 StreamController<T> _controllerInstance; |
| 143 Completer _controllerCompleter; | 143 Completer _controllerCompleter; |
| 144 bool _isClosed = false; | 144 bool _isClosed = false; |
| 145 bool _isBound = false; | 145 bool _isBound = false; |
| 146 bool _hasError = false; | 146 bool _hasError = false; |
| 147 | 147 |
| 148 _StreamSinkImpl(this._target); | 148 _StreamSinkImpl(this._target); |
| 149 | 149 |
| 150 void add(T data) { | 150 void add(T data) { |
| 151 if (_isClosed) return; | 151 if (_isClosed) throw new StateError("StreamSink is closed"); |
| 152 _controller.add(data); | 152 _controller.add(data); |
| 153 } | 153 } |
| 154 | 154 |
| 155 void addError(error, [StackTrace stackTrace]) { | 155 void addError(error, [StackTrace stackTrace]) { |
| 156 if (_isClosed) throw new StateError("StreamSink is closed"); |
| 156 _controller.addError(error, stackTrace); | 157 _controller.addError(error, stackTrace); |
| 157 } | 158 } |
| 158 | 159 |
| 159 Future addStream(Stream<T> stream) { | 160 Future addStream(Stream<T> stream) { |
| 160 if (_isBound) { | 161 if (_isBound) { |
| 161 throw new StateError("StreamSink is already bound to a stream"); | 162 throw new StateError("StreamSink is already bound to a stream"); |
| 162 } | 163 } |
| 163 _isBound = true; | 164 _isBound = true; |
| 164 if (_hasError) return done; | 165 if (_hasError) return done; |
| 165 // Wait for any sync operations to complete. | 166 // Wait for any sync operations to complete. |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 300 | 301 |
| 301 void writeln([Object object = ""]) { | 302 void writeln([Object object = ""]) { |
| 302 write(object); | 303 write(object); |
| 303 write("\n"); | 304 write("\n"); |
| 304 } | 305 } |
| 305 | 306 |
| 306 void writeCharCode(int charCode) { | 307 void writeCharCode(int charCode) { |
| 307 write(new String.fromCharCode(charCode)); | 308 write(new String.fromCharCode(charCode)); |
| 308 } | 309 } |
| 309 } | 310 } |
| OLD | NEW |