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 splits [String] values into individual lines. | 8 * This class splits [String] values into individual lines. |
9 */ | 9 */ |
10 class LineSplitter extends Converter<String, List<String>> { | 10 class LineSplitter extends Converter<String, List<String>> { |
11 | 11 |
12 const LineSplitter(); | 12 const LineSplitter(); |
13 | 13 |
14 List<String> convert(String data) { | 14 List<String> convert(String data) { |
15 var lines = new List<String>(); | 15 var lines = new List<String>(); |
16 | 16 |
17 _LineSplitterSink._addSlice(data, 0, data.length, true, lines.add); | 17 _LineSplitterSink._addSlice(data, 0, data.length, true, lines.add); |
18 | 18 |
19 return lines; | 19 return lines; |
20 } | 20 } |
21 | 21 |
22 StringConversionSink startChunkedConversion( | 22 StringConversionSink startChunkedConversion(Sink<String> sink) { |
23 ChunkedConversionSink<String> sink) { | |
24 | |
25 if (sink is! StringConversionSink) { | 23 if (sink is! StringConversionSink) { |
26 sink = new StringConversionSink.from(sink); | 24 sink = new StringConversionSink.from(sink); |
27 } | 25 } |
28 return new _LineSplitterSink(sink); | 26 return new _LineSplitterSink(sink); |
29 } | 27 } |
30 } | 28 } |
31 | 29 |
32 // TODO(floitsch): deal with utf8. | 30 // TODO(floitsch): deal with utf8. |
33 class _LineSplitterSink extends StringConversionSinkBase { | 31 class _LineSplitterSink extends StringConversionSinkBase { |
34 static const int _LF = 10; | 32 static const int _LF = 10; |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 if (isLast) { | 84 if (isLast) { |
87 // Add remaining | 85 // Add remaining |
88 adder(carry); | 86 adder(carry); |
89 } else { | 87 } else { |
90 return carry; | 88 return carry; |
91 } | 89 } |
92 } | 90 } |
93 return null; | 91 return null; |
94 } | 92 } |
95 } | 93 } |
OLD | NEW |