| 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.convert; | 5 part of dart.convert; |
| 6 | 6 |
| 7 typedef void _ChunkedConversionCallback<T>(T accumulated); | 7 typedef void _ChunkedConversionCallback<T>(T accumulated); |
| 8 | 8 |
| 9 /** | 9 /** |
| 10 * A [ChunkedConversionSink] is used to transmit data more efficiently between | 10 * A [ChunkedConversionSink] is used to transmit data more efficiently between |
| 11 * two converters during chunked conversions. | 11 * two converters during chunked conversions. |
| 12 * | 12 * |
| 13 * The basic `ChunkedConversionSink` is just a [Sink], and converters should | 13 * The basic `ChunkedConversionSink` is just a [Sink], and converters should |
| 14 * work with a plain `Sink`, but may work more efficiently with certain | 14 * work with a plain `Sink`, but may work more efficiently with certain |
| 15 * specialized types of `ChunkedConversionSink`. | 15 * specialized types of `ChunkedConversionSink`. |
| 16 * | 16 * |
| 17 * It is recommended that implementations of `ChunkedConversionSink` extends | 17 * It is recommended that implementations of `ChunkedConversionSink` extends |
| 18 * this class, to inherit any further methods that may be added to the class. | 18 * this class, to inherit any further methods that may be added to the class. |
| 19 */ | 19 */ |
| 20 abstract class ChunkedConversionSink<T> implements Sink<T> { | 20 abstract class ChunkedConversionSink<T> implements Sink<T> { |
| 21 ChunkedConversionSink(); | 21 ChunkedConversionSink(); |
| 22 factory ChunkedConversionSink.withCallback( | 22 factory ChunkedConversionSink.withCallback( |
| 23 void callback(List<T> accumulated)) = _SimpleCallbackSink; | 23 void callback(List<T> accumulated)) = _SimpleCallbackSink<T>; |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Adds chunked data to this sink. | 26 * Adds chunked data to this sink. |
| 27 * | 27 * |
| 28 * This method is also used when converters are used as [StreamTransformer]s. | 28 * This method is also used when converters are used as [StreamTransformer]s. |
| 29 */ | 29 */ |
| 30 void add(T chunk); | 30 void add(T chunk); |
| 31 | 31 |
| 32 /** | 32 /** |
| 33 * Closes the sink. | 33 * Closes the sink. |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 _ConverterStreamEventSink(Converter converter, EventSink<T> sink) | 85 _ConverterStreamEventSink(Converter converter, EventSink<T> sink) |
| 86 : this._eventSink = sink, | 86 : this._eventSink = sink, |
| 87 _chunkedSink = converter.startChunkedConversion(sink); | 87 _chunkedSink = converter.startChunkedConversion(sink); |
| 88 | 88 |
| 89 void add(S o) => _chunkedSink.add(o); | 89 void add(S o) => _chunkedSink.add(o); |
| 90 void addError(Object error, [StackTrace stackTrace]) { | 90 void addError(Object error, [StackTrace stackTrace]) { |
| 91 _eventSink.addError(error, stackTrace); | 91 _eventSink.addError(error, stackTrace); |
| 92 } | 92 } |
| 93 void close() => _chunkedSink.close(); | 93 void close() => _chunkedSink.close(); |
| 94 } | 94 } |
| OLD | NEW |