| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 implementations, | 6 * [StringBase] contains common methods used by concrete String implementations, |
| 7 * e.g., OneByteString. | 7 * e.g., OneByteString. |
| 8 */ | 8 */ |
| 9 class StringBase { | 9 class StringBase { |
| 10 | 10 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 StringBuffer buffer = new StringBuffer(); | 226 StringBuffer buffer = new StringBuffer(); |
| 227 int startIndex = 0; | 227 int startIndex = 0; |
| 228 for (Match match in pattern.allMatches(this)) { | 228 for (Match match in pattern.allMatches(this)) { |
| 229 buffer.add(this.substring(startIndex, match.start())).add(replacement); | 229 buffer.add(this.substring(startIndex, match.start())).add(replacement); |
| 230 startIndex = match.end(); | 230 startIndex = match.end(); |
| 231 } | 231 } |
| 232 return buffer.add(this.substring(startIndex)).toString(); | 232 return buffer.add(this.substring(startIndex)).toString(); |
| 233 } | 233 } |
| 234 | 234 |
| 235 /** | 235 /** |
| 236 * TODO(hausner): remove support for operator + and native method plus(). | |
| 237 */ | |
| 238 String plus(String other) native "String_plus"; | |
| 239 | |
| 240 /** | |
| 241 * Convert argument obj to string and concat it with this string. | |
| 242 * Returns concatenated string. | |
| 243 * TODO(hausner): remove support for +. | |
| 244 */ | |
| 245 String operator +(Object obj) { | |
| 246 return this.plus(obj.toString()); | |
| 247 } | |
| 248 | |
| 249 /** | |
| 250 * Convert all objects in [values] to strings and concat them | 236 * Convert all objects in [values] to strings and concat them |
| 251 * into a result string. | 237 * into a result string. |
| 252 */ | 238 */ |
| 253 static String _interpolate(List values) { | 239 static String _interpolate(List values) { |
| 254 int numValues = values.length; | 240 int numValues = values.length; |
| 255 List<String> stringList = new List<String>(numValues); | 241 List<String> stringList = new List<String>(numValues); |
| 256 int resultLength = 0; | 242 int resultLength = 0; |
| 257 for (int i = 0; i < numValues; i++) { | 243 for (int i = 0; i < numValues; i++) { |
| 258 String str = values[i].toString(); | 244 String str = values[i].toString(); |
| 259 resultLength += str.length; | 245 resultLength += str.length; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 511 for (int g in groups) { | 497 for (int g in groups) { |
| 512 result.add(group(g)); | 498 result.add(group(g)); |
| 513 } | 499 } |
| 514 return result; | 500 return result; |
| 515 } | 501 } |
| 516 | 502 |
| 517 final int _start; | 503 final int _start; |
| 518 final String str; | 504 final String str; |
| 519 final String pattern; | 505 final String pattern; |
| 520 } | 506 } |
| OLD | NEW |