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

Side by Side Diff: sdk/lib/convert/converter.dart

Issue 1964953003: Make dart:convert strong mode clean. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove unnecessary dynamics. Created 4 years, 7 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
« no previous file with comments | « sdk/lib/convert/codec.dart ('k') | sdk/lib/convert/encoding.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 /** 7 /**
8 * A [Converter] converts data from one representation into another. 8 * A [Converter] converts data from one representation into another.
9 * 9 *
10 * It is recommended that implementations of `Converter` extend this class, 10 * It is recommended that implementations of `Converter` extend this class,
11 * to inherit any further methods that may be added to the class. 11 * to inherit any further methods that may be added to the class.
12 */ 12 */
13 abstract class Converter<S, T> implements StreamTransformer { 13 abstract class Converter<S, T> implements StreamTransformer/*<S, T>*/ {
14 const Converter(); 14 const Converter();
15 15
16 /** 16 /**
17 * Converts [input] and returns the result of the conversion. 17 * Converts [input] and returns the result of the conversion.
18 */ 18 */
19 T convert(S input); 19 T convert(S input);
20 20
21 /** 21 /**
22 * Fuses `this` with [other]. 22 * Fuses `this` with [other].
23 * 23 *
24 * Encoding with the resulting converter is equivalent to converting with 24 * Encoding with the resulting converter is equivalent to converting with
25 * `this` before converting with `other`. 25 * `this` before converting with `other`.
26 */ 26 */
27 Converter<S, dynamic> fuse(Converter<T, dynamic> other) { 27 Converter<S, dynamic/*=TT*/> fuse/*<TT>*/(
28 return new _FusedConverter<S, T, dynamic>(this, other); 28 Converter<T, dynamic/*=TT*/> other) {
29 return new _FusedConverter<S, T, dynamic/*=TT*/>(this, other);
29 } 30 }
30 31
31 /** 32 /**
32 * Deprecated. 33 * Starts a chunked conversion.
33 * 34 *
34 * Use the [ChunkedConverter] interface instead. 35 * The returned sink serves as input for the long-running conversion. The
36 * given [sink] serves as output.
35 */ 37 */
36 @deprecated 38 Sink/*<S>*/ startChunkedConversion(Sink/*<T>*/ sink) {
37 ChunkedConversionSink startChunkedConversion(Sink sink) {
38 throw new UnsupportedError( 39 throw new UnsupportedError(
39 "This converter does not support chunked conversions: $this"); 40 "This converter does not support chunked conversions: $this");
40 } 41 }
41 42
42 /** 43 Stream/*<T>*/ bind(Stream/*<S>*/ stream) {
43 * Deprecated. 44 return new Stream/*<T>*/.eventTransformed(
44 *
45 * Use the [ChunkedConverter] interface instead.
46 */
47 @deprecated
48 Stream bind(Stream stream) {
49 return new Stream.eventTransformed(
50 stream, 45 stream,
51 (EventSink sink) => new _ConverterStreamEventSink(this, sink)); 46 (EventSink sink) => new _ConverterStreamEventSink(this, sink));
52 } 47 }
53 } 48 }
54 49
55 /** 50 /**
56 * Fuses two converters. 51 * Fuses two converters.
57 * 52 *
58 * For a non-chunked conversion converts the input in sequence. 53 * For a non-chunked conversion converts the input in sequence.
59 */ 54 */
60 class _FusedConverter<S, M, T> extends Converter<S, T> { 55 class _FusedConverter<S, M, T> extends Converter<S, T> {
61 final Converter<S, M> _first; 56 final Converter<S, M> _first;
62 final Converter<M, T> _second; 57 final Converter<M, T> _second;
63 58
64 _FusedConverter(this._first, this._second); 59 _FusedConverter(this._first, this._second);
65 60
66 T convert(S input) => _second.convert(_first.convert(input)); 61 T convert(S input) => _second.convert(_first.convert(input));
62
63 Sink/*<S>*/ startChunkedConversion(Sink/*<T>*/ sink) {
64 return _first.startChunkedConversion(_second.startChunkedConversion(sink));
65 }
67 } 66 }
OLDNEW
« no previous file with comments | « sdk/lib/convert/codec.dart ('k') | sdk/lib/convert/encoding.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698