| 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 * [_StringBase] contains common methods used by concrete String | 6 * [_StringBase] contains common methods used by concrete String |
| 7 * implementations, e.g., _OneByteString. | 7 * implementations, e.g., _OneByteString. |
| 8 */ | 8 */ |
| 9 class _StringBase { | 9 class _StringBase { |
| 10 | 10 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return index; | 137 return index; |
| 138 } | 138 } |
| 139 } | 139 } |
| 140 return -1; | 140 return -1; |
| 141 } | 141 } |
| 142 | 142 |
| 143 String substring(int startIndex, [int endIndex]) { | 143 String substring(int startIndex, [int endIndex]) { |
| 144 if (endIndex === null) endIndex = this.length; | 144 if (endIndex === null) endIndex = this.length; |
| 145 | 145 |
| 146 if ((startIndex < 0) || (startIndex > this.length)) { | 146 if ((startIndex < 0) || (startIndex > this.length)) { |
| 147 throw new IndexOutOfRangeException(startIndex); | 147 throw new RangeError.value(startIndex); |
| 148 } | 148 } |
| 149 if ((endIndex < 0) || (endIndex > this.length)) { | 149 if ((endIndex < 0) || (endIndex > this.length)) { |
| 150 throw new IndexOutOfRangeException(endIndex); | 150 throw new RangeError.value(endIndex); |
| 151 } | 151 } |
| 152 if (startIndex > endIndex) { | 152 if (startIndex > endIndex) { |
| 153 throw new IndexOutOfRangeException(startIndex); | 153 throw new RangeError.value(startIndex); |
| 154 } | 154 } |
| 155 return _substringUnchecked(startIndex, endIndex); | 155 return _substringUnchecked(startIndex, endIndex); |
| 156 } | 156 } |
| 157 | 157 |
| 158 String _substringUnchecked(int startIndex, int endIndex) | 158 String _substringUnchecked(int startIndex, int endIndex) |
| 159 native "StringBase_substringUnchecked"; | 159 native "StringBase_substringUnchecked"; |
| 160 | 160 |
| 161 String trim() { | 161 String trim() { |
| 162 final int len = this.length; | 162 final int len = this.length; |
| 163 int first = 0; | 163 int first = 0; |
| (...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 461 const _StringMatch(int this.start, | 461 const _StringMatch(int this.start, |
| 462 String this.str, | 462 String this.str, |
| 463 String this.pattern); | 463 String this.pattern); |
| 464 | 464 |
| 465 int get end => start + pattern.length; | 465 int get end => start + pattern.length; |
| 466 String operator[](int g) => group(g); | 466 String operator[](int g) => group(g); |
| 467 int get groupCount => 0; | 467 int get groupCount => 0; |
| 468 | 468 |
| 469 String group(int group) { | 469 String group(int group) { |
| 470 if (group != 0) { | 470 if (group != 0) { |
| 471 throw new IndexOutOfRangeException(group); | 471 throw new RangeError.value(group); |
| 472 } | 472 } |
| 473 return pattern; | 473 return pattern; |
| 474 } | 474 } |
| 475 | 475 |
| 476 List<String> groups(List<int> groups) { | 476 List<String> groups(List<int> groups) { |
| 477 List<String> result = new List<String>(); | 477 List<String> result = new List<String>(); |
| 478 for (int g in groups) { | 478 for (int g in groups) { |
| 479 result.add(group(g)); | 479 result.add(group(g)); |
| 480 } | 480 } |
| 481 return result; | 481 return result; |
| 482 } | 482 } |
| 483 | 483 |
| 484 final int start; | 484 final int start; |
| 485 final String str; | 485 final String str; |
| 486 final String pattern; | 486 final String pattern; |
| 487 } | 487 } |
| OLD | NEW |