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 /** | 7 /** |
8 * A [Codec] encodes and (if supported) decodes data. | 8 * A [Codec] encodes and (if supported) decodes data. |
9 * | 9 * |
10 * Codecs can be fused. For example fusing [JSON] and [UTF8] produces | 10 * Codecs can be fused. For example fusing [JSON] and [UTF8] produces |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 /** | 77 /** |
78 * Fuses the given codecs. | 78 * Fuses the given codecs. |
79 * | 79 * |
80 * In the non-chunked conversion simply invokes the non-chunked conversions in | 80 * In the non-chunked conversion simply invokes the non-chunked conversions in |
81 * sequence. | 81 * sequence. |
82 */ | 82 */ |
83 class _FusedCodec<S, M, T> extends Codec<S, T> { | 83 class _FusedCodec<S, M, T> extends Codec<S, T> { |
84 final Codec<S, M> _first; | 84 final Codec<S, M> _first; |
85 final Codec<M, T> _second; | 85 final Codec<M, T> _second; |
86 | 86 |
87 Converter<S, T> get encoder => _first.encoder.fuse(_second.encoder); | 87 Converter<S, T> get encoder => _first.encoder.fuse/*<T>*/(_second.encoder); |
88 Converter<T, S> get decoder => _second.decoder.fuse(_first.decoder); | 88 Converter<T, S> get decoder => _second.decoder.fuse/*<S>*/(_first.decoder); |
89 | 89 |
90 _FusedCodec(this._first, this._second); | 90 _FusedCodec(this._first, this._second); |
91 } | 91 } |
92 | 92 |
93 class _InvertedCodec<T, S> extends Codec<T, S> { | 93 class _InvertedCodec<T, S> extends Codec<T, S> { |
94 final Codec<S, T> _codec; | 94 final Codec<S, T> _codec; |
95 | 95 |
96 _InvertedCodec(Codec<S, T> codec) : _codec = codec; | 96 _InvertedCodec(Codec<S, T> codec) : _codec = codec; |
97 | 97 |
98 Converter<T, S> get encoder => _codec.decoder; | 98 Converter<T, S> get encoder => _codec.decoder; |
99 Converter<S, T> get decoder => _codec.encoder; | 99 Converter<S, T> get decoder => _codec.encoder; |
100 | 100 |
101 Codec<S, T> get inverted => _codec; | 101 Codec<S, T> get inverted => _codec; |
102 } | 102 } |
OLD | NEW |