| 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 * This class provides an interface for converters to | 8 * This class provides an interface for converters to |
| 9 * efficiently transmit String data. | 9 * efficiently transmit String data. |
| 10 * | 10 * |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 ClosableStringSink asStringSink() { | 186 ClosableStringSink asStringSink() { |
| 187 return new _StringConversionSinkAsStringSinkAdapter(this); | 187 return new _StringConversionSinkAsStringSinkAdapter(this); |
| 188 } | 188 } |
| 189 } | 189 } |
| 190 | 190 |
| 191 /** | 191 /** |
| 192 * This class is a [StringConversionSink] that wraps a [StringSink]. | 192 * This class is a [StringConversionSink] that wraps a [StringSink]. |
| 193 */ | 193 */ |
| 194 class _StringSinkConversionSink extends StringConversionSinkBase { | 194 class _StringSinkConversionSink extends StringConversionSinkBase { |
| 195 StringSink _stringSink; | 195 StringSink _stringSink; |
| 196 _StringSinkConversionSink(StringSink this._stringSink); | 196 _StringSinkConversionSink(this._stringSink); |
| 197 | 197 |
| 198 void close() {} | 198 void close() {} |
| 199 void addSlice(String str, int start, int end, bool isLast) { | 199 void addSlice(String str, int start, int end, bool isLast) { |
| 200 if (start != 0 || end != str.length) { | 200 if (start != 0 || end != str.length) { |
| 201 for (int i = start; i < end; i++) { | 201 for (int i = start; i < end; i++) { |
| 202 _stringSink.writeCharCode(str.codeUnitAt(i)); | 202 _stringSink.writeCharCode(str.codeUnitAt(i)); |
| 203 } | 203 } |
| 204 } else { | 204 } else { |
| 205 _stringSink.write(str); | 205 _stringSink.write(str); |
| 206 } | 206 } |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 _decoder.convert(chunk, startIndex, endIndex); | 333 _decoder.convert(chunk, startIndex, endIndex); |
| 334 if (_buffer.isNotEmpty) { | 334 if (_buffer.isNotEmpty) { |
| 335 String accumulated = _buffer.toString(); | 335 String accumulated = _buffer.toString(); |
| 336 _chunkedSink.addSlice(accumulated, 0, accumulated.length, isLast); | 336 _chunkedSink.addSlice(accumulated, 0, accumulated.length, isLast); |
| 337 _buffer.clear(); | 337 _buffer.clear(); |
| 338 return; | 338 return; |
| 339 } | 339 } |
| 340 if (isLast) close(); | 340 if (isLast) close(); |
| 341 } | 341 } |
| 342 } | 342 } |
| OLD | NEW |