| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 | 5 |
| 6 part of intl; | 6 part of intl; |
| 7 | 7 |
| 8 /** | 8 /** |
| 9 * A class for holding onto the data for a date so that it can be built | 9 * A class for holding onto the data for a date so that it can be built |
| 10 * up incrementally. | 10 * up incrementally. |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 * Does not modify the stream position. | 91 * Does not modify the stream position. |
| 92 */ | 92 */ |
| 93 peek([howMany = 1]) { | 93 peek([howMany = 1]) { |
| 94 var result; | 94 var result; |
| 95 if (contents is String) { | 95 if (contents is String) { |
| 96 result = contents.substring( | 96 result = contents.substring( |
| 97 index, | 97 index, |
| 98 min(index + howMany, contents.length)); | 98 min(index + howMany, contents.length)); |
| 99 } else { | 99 } else { |
| 100 // Assume List | 100 // Assume List |
| 101 result = contents.getRange(index, howMany); | 101 result = contents.sublist(index, index + howMany); |
| 102 } | 102 } |
| 103 return result; | 103 return result; |
| 104 } | 104 } |
| 105 | 105 |
| 106 /** Return the remaining contents of the stream */ | 106 /** Return the remaining contents of the stream */ |
| 107 rest() => peek(contents.length - index); | 107 rest() => peek(contents.length - index); |
| 108 | 108 |
| 109 /** | 109 /** |
| 110 * Find the index of the first element for which [f] returns true. | 110 * Find the index of the first element for which [f] returns true. |
| 111 * Advances the stream to that position. | 111 * Advances the stream to that position. |
| (...skipping 22 matching lines...) Expand all Loading... |
| 134 * can see and then return the corresponding integer. Advance the stream. | 134 * can see and then return the corresponding integer. Advance the stream. |
| 135 */ | 135 */ |
| 136 var digitMatcher = new RegExp(r'\d+'); | 136 var digitMatcher = new RegExp(r'\d+'); |
| 137 int nextInteger() { | 137 int nextInteger() { |
| 138 var string = digitMatcher.stringMatch(rest()); | 138 var string = digitMatcher.stringMatch(rest()); |
| 139 if (string == null || string.isEmpty) return null; | 139 if (string == null || string.isEmpty) return null; |
| 140 read(string.length); | 140 read(string.length); |
| 141 return int.parse(string); | 141 return int.parse(string); |
| 142 } | 142 } |
| 143 } | 143 } |
| OLD | NEW |