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 "convert.dart"; | 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 |
11 * an encoder that can convert Json objects directly to bytes, or can decode | 11 * an encoder that can convert Json objects directly to bytes, or can decode |
12 * bytes directly to json objects. | 12 * bytes directly to json objects. |
13 * | 13 * |
14 * Fused codecs generally attempt to optimize the operations and can be faster | 14 * Fused codecs generally attempt to optimize the operations and can be faster |
15 * than executing each step of an encoding separately. | 15 * than executing each step of an encoding separately. |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 class _InvertedCodec<T, S> extends Codec<T, S> { | 91 class _InvertedCodec<T, S> extends Codec<T, S> { |
92 final Codec<S, T> _codec; | 92 final Codec<S, T> _codec; |
93 | 93 |
94 _InvertedCodec(Codec<S, T> codec) : _codec = codec; | 94 _InvertedCodec(Codec<S, T> codec) : _codec = codec; |
95 | 95 |
96 Converter<T, S> get encoder => _codec.decoder; | 96 Converter<T, S> get encoder => _codec.decoder; |
97 Converter<S, T> get decoder => _codec.encoder; | 97 Converter<S, T> get decoder => _codec.encoder; |
98 | 98 |
99 Codec<S, T> get inverted => _codec; | 99 Codec<S, T> get inverted => _codec; |
100 } | 100 } |
OLD | NEW |